Skip to content

Commit

Permalink
usbip: usbip_detach: Fix memory, udev context and udev leak
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Shuah Khan (Samsung OSG) authored and Greg Kroah-Hartman committed May 31, 2018
1 parent edf3800 commit d179f99
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/usb/usbip/src/usbip_detach.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -73,9 +73,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;
Expand Down

0 comments on commit d179f99

Please sign in to comment.