diff options
author | Yuyang Du <yuyang.du@intel.com> | 2017-05-22 06:20:18 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-06-13 04:48:24 -0400 |
commit | e55dea8ede2245918c537b9a252a1269f5d7b78b (patch) | |
tree | d1cada6c6559989bd867ef11e7743ff470cc5b7c /tools/usb/usbip/libsrc | |
parent | fd92b7deb98a4edd31ffcc2d64cee36103805ff5 (diff) |
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>
Diffstat (limited to 'tools/usb/usbip/libsrc')
-rw-r--r-- | tools/usb/usbip/libsrc/vhci_driver.c | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/tools/usb/usbip/libsrc/vhci_driver.c b/tools/usb/usbip/libsrc/vhci_driver.c index aa82c4b17797..f519c73c6d99 100644 --- a/tools/usb/usbip/libsrc/vhci_driver.c +++ b/tools/usb/usbip/libsrc/vhci_driver.c | |||
@@ -36,18 +36,11 @@ err: | |||
36 | return NULL; | 36 | return NULL; |
37 | } | 37 | } |
38 | 38 | ||
39 | |||
40 | |||
41 | static int parse_status(const char *value) | 39 | static int parse_status(const char *value) |
42 | { | 40 | { |
43 | int ret = 0; | 41 | int ret = 0; |
44 | char *c; | 42 | char *c; |
45 | 43 | ||
46 | |||
47 | for (int i = 0; i < vhci_driver->nports; i++) | ||
48 | memset(&vhci_driver->idev[i], 0, sizeof(vhci_driver->idev[i])); | ||
49 | |||
50 | |||
51 | /* skip a header line */ | 44 | /* skip a header line */ |
52 | c = strchr(value, '\n'); | 45 | c = strchr(value, '\n'); |
53 | if (!c) | 46 | if (!c) |
@@ -58,6 +51,7 @@ static int parse_status(const char *value) | |||
58 | int port, status, speed, devid; | 51 | int port, status, speed, devid; |
59 | unsigned long socket; | 52 | unsigned long socket; |
60 | char lbusid[SYSFS_BUS_ID_SIZE]; | 53 | char lbusid[SYSFS_BUS_ID_SIZE]; |
54 | struct usbip_imported_device *idev; | ||
61 | 55 | ||
62 | ret = sscanf(c, "%d %d %d %x %lx %31s\n", | 56 | ret = sscanf(c, "%d %d %d %x %lx %31s\n", |
63 | &port, &status, &speed, | 57 | &port, &status, &speed, |
@@ -72,30 +66,28 @@ static int parse_status(const char *value) | |||
72 | port, status, speed, devid); | 66 | port, status, speed, devid); |
73 | dbg("socket %lx lbusid %s", socket, lbusid); | 67 | dbg("socket %lx lbusid %s", socket, lbusid); |
74 | 68 | ||
75 | |||
76 | /* if a device is connected, look at it */ | 69 | /* if a device is connected, look at it */ |
77 | { | 70 | idev = &vhci_driver->idev[port]; |
78 | struct usbip_imported_device *idev = &vhci_driver->idev[port]; | ||
79 | 71 | ||
80 | idev->port = port; | 72 | memset(idev, 0, sizeof(*idev)); |
81 | idev->status = status; | ||
82 | 73 | ||
83 | idev->devid = devid; | 74 | idev->port = port; |
75 | idev->status = status; | ||
84 | 76 | ||
85 | idev->busnum = (devid >> 16); | 77 | idev->devid = devid; |
86 | idev->devnum = (devid & 0x0000ffff); | ||
87 | 78 | ||
88 | if (idev->status != VDEV_ST_NULL | 79 | idev->busnum = (devid >> 16); |
89 | && idev->status != VDEV_ST_NOTASSIGNED) { | 80 | idev->devnum = (devid & 0x0000ffff); |
90 | idev = imported_device_init(idev, lbusid); | 81 | |
91 | if (!idev) { | 82 | if (idev->status != VDEV_ST_NULL |
92 | dbg("imported_device_init failed"); | 83 | && idev->status != VDEV_ST_NOTASSIGNED) { |
93 | return -1; | 84 | idev = imported_device_init(idev, lbusid); |
94 | } | 85 | if (!idev) { |
86 | dbg("imported_device_init failed"); | ||
87 | return -1; | ||
95 | } | 88 | } |
96 | } | 89 | } |
97 | 90 | ||
98 | |||
99 | /* go to the next line */ | 91 | /* go to the next line */ |
100 | c = strchr(c, '\n'); | 92 | c = strchr(c, '\n'); |
101 | if (!c) | 93 | if (!c) |