aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShuah Khan (Samsung OSG) <shuah@kernel.org>2018-05-29 18:13:03 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-31 06:44:39 -0400
commitd179f99a651685b19333360e6558110da2fe9bd7 (patch)
treef1e392a64d7d3ca93cb6dc3726dd6d78e1f788e9
parentedf380046b0a726de26fc29015556a11288940ac (diff)
usbip: usbip_detach: Fix memory, udev context and udev leak
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>
-rw-r--r--tools/usb/usbip/src/usbip_detach.c9
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 9db9d21bb2ec..6a8db858caa5 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)
43 43
44static int detach_port(char *port) 44static int detach_port(char *port)
45{ 45{
46 int ret; 46 int ret = 0;
47 uint8_t portnum; 47 uint8_t portnum;
48 char path[PATH_MAX+1]; 48 char path[PATH_MAX+1];
49 49
@@ -73,9 +73,12 @@ static int detach_port(char *port)
73 } 73 }
74 74
75 ret = usbip_vhci_detach_device(portnum); 75 ret = usbip_vhci_detach_device(portnum);
76 if (ret < 0) 76 if (ret < 0) {
77 return -1; 77 ret = -1;
78 goto call_driver_close;
79 }
78 80
81call_driver_close:
79 usbip_vhci_driver_close(); 82 usbip_vhci_driver_close();
80 83
81 return ret; 84 return ret;