Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e55dea8e authored by Yuyang Du's avatar Yuyang Du Committed by Greg Kroah-Hartman
Browse files

usb: usbip tool: Fix parse_status()



In parse_status(), all nports number of idev's are initiated to
0 by memset(), it is simply wrong, because parse_status() reads
the status sys file one by one, therefore, it can only update the
according vhci_driver->idev's for it to parse.

Reviewed-by: default avatarKrzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: default avatarYuyang Du <yuyang.du@intel.com>
Acked-by: default avatarShuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fd92b7de
Loading
Loading
Loading
Loading
+15 −23
Original line number Diff line number Diff line
@@ -36,18 +36,11 @@ imported_device_init(struct usbip_imported_device *idev, char *busid)
	return NULL;
}



static int parse_status(const char *value)
{
	int ret = 0;
	char *c;


	for (int i = 0; i < vhci_driver->nports; i++)
		memset(&vhci_driver->idev[i], 0, sizeof(vhci_driver->idev[i]));


	/* skip a header line */
	c = strchr(value, '\n');
	if (!c)
@@ -58,6 +51,7 @@ static int parse_status(const char *value)
		int port, status, speed, devid;
		unsigned long socket;
		char lbusid[SYSFS_BUS_ID_SIZE];
		struct usbip_imported_device *idev;

		ret = sscanf(c, "%d %d %d %x %lx %31s\n",
				&port, &status, &speed,
@@ -72,10 +66,10 @@ static int parse_status(const char *value)
				port, status, speed, devid);
		dbg("socket %lx lbusid %s", socket, lbusid);


		/* if a device is connected, look at it */
		{
			struct usbip_imported_device *idev = &vhci_driver->idev[port];
		idev = &vhci_driver->idev[port];

		memset(idev, 0, sizeof(*idev));

		idev->port	= port;
		idev->status	= status;
@@ -93,8 +87,6 @@ static int parse_status(const char *value)
				return -1;
			}
		}
		}


		/* go to the next line */
		c = strchr(c, '\n');
+2 −0
Original line number Diff line number Diff line
@@ -108,6 +108,8 @@ static int import_device(int sockfd, struct usbip_usb_device *udev)
		return -1;
	}

	dbg("got free port %d", port);

	rc = usbip_vhci_attach_device(port, sockfd, udev->busnum,
				      udev->devnum, udev->speed);
	if (rc < 0) {