diff options
author | Shuah Khan (Samsung OSG) <shuah@kernel.org> | 2018-05-29 16:13:03 -0600 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-08-09 12:20:26 +0200 |
commit | 031e96b6ffde712a300b7697bc8375351eb8bccf (patch) | |
tree | 9ffc4282665d6c2a4e875d0751960d3cb7120b3d /tools | |
parent | b3ab448458ed69f6cb3c408c30d38e29acc06001 (diff) | |
download | linux-stable-031e96b6ffde712a300b7697bc8375351eb8bccf.tar.gz linux-stable-031e96b6ffde712a300b7697bc8375351eb8bccf.tar.bz2 linux-stable-031e96b6ffde712a300b7697bc8375351eb8bccf.zip |
usbip: usbip_detach: Fix memory, udev context and udev leak
[ Upstream commit d179f99a651685b19333360e6558110da2fe9bd7 ]
detach_port() fails to call usbip_vhci_driver_close() from its error
path after usbip_vhci_detach_device() returns failure, leaking memory
allocated in usbip_vhci_driver_open() and holding udev_context and udev
references. Fix it to call usbip_vhci_driver_close().
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/usb/usbip/src/usbip_detach.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/usb/usbip/src/usbip_detach.c b/tools/usb/usbip/src/usbip_detach.c index 05c6d15856eb..b4356ed875e5 100644 --- a/tools/usb/usbip/src/usbip_detach.c +++ b/tools/usb/usbip/src/usbip_detach.c @@ -43,7 +43,7 @@ void usbip_detach_usage(void) static int detach_port(char *port) { - int ret; + int ret = 0; uint8_t portnum; char path[PATH_MAX+1]; @@ -71,9 +71,12 @@ static int detach_port(char *port) } ret = usbip_vhci_detach_device(portnum); - if (ret < 0) - return -1; + if (ret < 0) { + ret = -1; + goto call_driver_close; + } +call_driver_close: usbip_vhci_driver_close(); return ret; |