mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 07:38:10 +00:00
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: Krzysztof Opasiak <k.opasiak@samsung.com> Signed-off-by: Yuyang Du <yuyang.du@intel.com> Acked-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
fd92b7deb9
commit
e55dea8ede
2 changed files with 17 additions and 23 deletions
|
@ -36,18 +36,11 @@ imported_device_init(struct usbip_imported_device *idev, char *busid)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int parse_status(const char *value)
|
static int parse_status(const char *value)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char *c;
|
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 */
|
/* skip a header line */
|
||||||
c = strchr(value, '\n');
|
c = strchr(value, '\n');
|
||||||
if (!c)
|
if (!c)
|
||||||
|
@ -58,6 +51,7 @@ static int parse_status(const char *value)
|
||||||
int port, status, speed, devid;
|
int port, status, speed, devid;
|
||||||
unsigned long socket;
|
unsigned long socket;
|
||||||
char lbusid[SYSFS_BUS_ID_SIZE];
|
char lbusid[SYSFS_BUS_ID_SIZE];
|
||||||
|
struct usbip_imported_device *idev;
|
||||||
|
|
||||||
ret = sscanf(c, "%d %d %d %x %lx %31s\n",
|
ret = sscanf(c, "%d %d %d %x %lx %31s\n",
|
||||||
&port, &status, &speed,
|
&port, &status, &speed,
|
||||||
|
@ -72,30 +66,28 @@ static int parse_status(const char *value)
|
||||||
port, status, speed, devid);
|
port, status, speed, devid);
|
||||||
dbg("socket %lx lbusid %s", socket, lbusid);
|
dbg("socket %lx lbusid %s", socket, lbusid);
|
||||||
|
|
||||||
|
|
||||||
/* if a device is connected, look at it */
|
/* if a device is connected, look at it */
|
||||||
{
|
idev = &vhci_driver->idev[port];
|
||||||
struct usbip_imported_device *idev = &vhci_driver->idev[port];
|
|
||||||
|
|
||||||
idev->port = port;
|
memset(idev, 0, sizeof(*idev));
|
||||||
idev->status = status;
|
|
||||||
|
|
||||||
idev->devid = devid;
|
idev->port = port;
|
||||||
|
idev->status = status;
|
||||||
|
|
||||||
idev->busnum = (devid >> 16);
|
idev->devid = devid;
|
||||||
idev->devnum = (devid & 0x0000ffff);
|
|
||||||
|
|
||||||
if (idev->status != VDEV_ST_NULL
|
idev->busnum = (devid >> 16);
|
||||||
&& idev->status != VDEV_ST_NOTASSIGNED) {
|
idev->devnum = (devid & 0x0000ffff);
|
||||||
idev = imported_device_init(idev, lbusid);
|
|
||||||
if (!idev) {
|
if (idev->status != VDEV_ST_NULL
|
||||||
dbg("imported_device_init failed");
|
&& idev->status != VDEV_ST_NOTASSIGNED) {
|
||||||
return -1;
|
idev = imported_device_init(idev, lbusid);
|
||||||
}
|
if (!idev) {
|
||||||
|
dbg("imported_device_init failed");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* go to the next line */
|
/* go to the next line */
|
||||||
c = strchr(c, '\n');
|
c = strchr(c, '\n');
|
||||||
if (!c)
|
if (!c)
|
||||||
|
|
|
@ -108,6 +108,8 @@ static int import_device(int sockfd, struct usbip_usb_device *udev)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbg("got free port %d", port);
|
||||||
|
|
||||||
rc = usbip_vhci_attach_device(port, sockfd, udev->busnum,
|
rc = usbip_vhci_attach_device(port, sockfd, udev->busnum,
|
||||||
udev->devnum, udev->speed);
|
udev->devnum, udev->speed);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
|
|
Loading…
Reference in a new issue