提交 c3509715 编写于 作者: Y Yuyang Du 提交者: Greg Kroah-Hartman

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 0775a9cb ("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: NKrzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: NYuyang Du <yuyang.du@intel.com>
Acked-by: NShuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 b3b51417
......@@ -220,9 +220,16 @@ int usbip_vhci_driver_open(void)
}
vhci_driver->nports = get_nports();
dbg("available ports: %d", vhci_driver->nports);
if (vhci_driver->nports <= 0) {
err("no available ports");
goto err;
} else if (vhci_driver->nports > MAXNPORT) {
err("port number exceeds %d", MAXNPORT);
goto err;
}
if (refresh_imported_device_list())
goto err;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册