[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180409002239.163177-53-alexander.levin@microsoft.com>
Date: Mon, 9 Apr 2018 00:23:31 +0000
From: Sasha Levin <Alexander.Levin@...rosoft.com>
To: "stable@...r.kernel.org" <stable@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC: Yuyang Du <yuyang.du@...el.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Sasha Levin <Alexander.Levin@...rosoft.com>
Subject: [PATCH AUTOSEL for 4.9 053/293] usb: usbip tool: Check the return of
get_nports()
From: Yuyang Du <yuyang.du@...el.com>
[ Upstream commit c3509715fc9484a48b69a9f0196b728c960840c9 ]
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@...sung.com>
Signed-off-by: Yuyang Du <yuyang.du@...el.com>
Acked-by: Shuah Khan <shuahkh@....samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@...rosoft.com>
---
tools/usb/usbip/libsrc/vhci_driver.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tools/usb/usbip/libsrc/vhci_driver.c b/tools/usb/usbip/libsrc/vhci_driver.c
index 1274f326242c..c589cfbd1cfe 100644
--- a/tools/usb/usbip/libsrc/vhci_driver.c
+++ b/tools/usb/usbip/libsrc/vhci_driver.c
@@ -238,9 +238,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;
--
2.15.1
Powered by blists - more mailing lists