Commit f7a5d7b3 authored by Elad Wexler's avatar Elad Wexler Committed by Greg Kroah-Hartman

tools: usb: usbip: fix fd leak in case of 'fread' failure

Fix possible resource leak: fd
Signed-off-by: default avatarElad Wexler <elad.wexler@gmail.com>
Acked-by: default avatarShuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cb483264
...@@ -92,7 +92,7 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev) ...@@ -92,7 +92,7 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev)
return -1; return -1;
ret = fread((char *) &descr, sizeof(descr), 1, fd); ret = fread((char *) &descr, sizeof(descr), 1, fd);
if (ret < 0) if (ret < 0)
return -1; goto err;
fclose(fd); fclose(fd);
copy_descr_attr(dev, &descr, bDeviceClass); 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,6 +124,9 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev)
name = udev_device_get_sysname(plat); name = udev_device_get_sysname(plat);
strncpy(dev->busid, name, SYSFS_BUS_ID_SIZE); strncpy(dev->busid, name, SYSFS_BUS_ID_SIZE);
return 0; return 0;
err:
fclose(fd);
return -1;
} }
static int is_my_device(struct udev_device *dev) static int is_my_device(struct udev_device *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment