aboutsummaryrefslogtreecommitdiffstats
path: root/tools/usb/usbip/libsrc
diff options
context:
space:
mode:
authorElad Wexler <elad.wexler@gmail.com>2017-12-30 11:01:39 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-01-04 11:05:55 -0500
commitf7a5d7b3ab3c4865af85b431e1cd18b66b6c3b0e (patch)
tree27125367abd5f9c54c204b4aa82f95a5c3ab6dca /tools/usb/usbip/libsrc
parentcb48326493146b1022702b9b8f15460f7e9dbfc1 (diff)
tools: usb: usbip: fix fd leak in case of 'fread' failure
Fix possible resource leak: fd Signed-off-by: Elad Wexler <elad.wexler@gmail.com> Acked-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/usb/usbip/libsrc')
-rw-r--r--tools/usb/usbip/libsrc/usbip_device_driver.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/usb/usbip/libsrc/usbip_device_driver.c b/tools/usb/usbip/libsrc/usbip_device_driver.c
index b2dac82975af..ec3a0b794f15 100644
--- a/tools/usb/usbip/libsrc/usbip_device_driver.c
+++ b/tools/usb/usbip/libsrc/usbip_device_driver.c
@@ -92,7 +92,7 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev)
92 return -1; 92 return -1;
93 ret = fread((char *) &descr, sizeof(descr), 1, fd); 93 ret = fread((char *) &descr, sizeof(descr), 1, fd);
94 if (ret < 0) 94 if (ret < 0)
95 return -1; 95 goto err;
96 fclose(fd); 96 fclose(fd);
97 97
98 copy_descr_attr(dev, &descr, bDeviceClass); 98 copy_descr_attr(dev, &descr, bDeviceClass);
@@ -124,6 +124,9 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev)
124 name = udev_device_get_sysname(plat); 124 name = udev_device_get_sysname(plat);
125 strncpy(dev->busid, name, SYSFS_BUS_ID_SIZE); 125 strncpy(dev->busid, name, SYSFS_BUS_ID_SIZE);
126 return 0; 126 return 0;
127err:
128 fclose(fd);
129 return -1;
127} 130}
128 131
129static int is_my_device(struct udev_device *dev) 132static int is_my_device(struct udev_device *dev)