aboutsummaryrefslogtreecommitdiffstats
path: root/tools/usb/usbip/libsrc
diff options
context:
space:
mode:
authorYuyang Du <yuyang.du@intel.com>2017-05-22 06:20:15 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-06-13 04:48:24 -0400
commitc3509715fc9484a48b69a9f0196b728c960840c9 (patch)
tree9f1e1b73a8d366d6a19bf00925a26f1f285ad822 /tools/usb/usbip/libsrc
parentb3b51417d0af63fb9a06662dc292200aed9ea53f (diff)
usb: usbip tool: Check the return of get_nports()
If we get nonpositive number of ports, there is no sense to continue, then fail gracefully. In addition, the commit 0775a9cbc694e8c72 ("usbip: vhci extension: modifications to vhci driver") introduced configurable numbers of controllers and ports, but we have a static port number maximum, MAXNPORT. If exceeded, the idev array will be overflown. We fix it by validating the nports to make sure the port number max is not exceeded. 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.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/usb/usbip/libsrc/vhci_driver.c b/tools/usb/usbip/libsrc/vhci_driver.c
index f659c146cdc8..036b62be0fc7 100644
--- a/tools/usb/usbip/libsrc/vhci_driver.c
+++ b/tools/usb/usbip/libsrc/vhci_driver.c
@@ -220,9 +220,16 @@ int usbip_vhci_driver_open(void)
220 } 220 }
221 221
222 vhci_driver->nports = get_nports(); 222 vhci_driver->nports = get_nports();
223
224 dbg("available ports: %d", vhci_driver->nports); 223 dbg("available ports: %d", vhci_driver->nports);
225 224
225 if (vhci_driver->nports <= 0) {
226 err("no available ports");
227 goto err;
228 } else if (vhci_driver->nports > MAXNPORT) {
229 err("port number exceeds %d", MAXNPORT);
230 goto err;
231 }
232
226 if (refresh_imported_device_list()) 233 if (refresh_imported_device_list())
227 goto err; 234 goto err;
228 235