* tools: usb: usbip: fix fd leak in case of 'fread' failure
@ 2017-12-30 16:01 Elad Wexler
0 siblings, 0 replies; 2+ messages in thread
From: Elad Wexler @ 2017-12-30 16:01 UTC (permalink / raw)
To: valentina.manea.m, shuah; +Cc: linux-usb, linux-kernel
Fix possible resource leak: fd
Signed-off-by: Elad Wexler <elad.wexler@gmail.com>
---
tools/usb/usbip/libsrc/usbip_device_driver.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/usb/usbip/libsrc/usbip_device_driver.c b/tools/usb/usbip/libsrc/usbip_device_driver.c
index e059b7d..1aa27af 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)
return -1;
ret = fread((char *) &descr, sizeof(descr), 1, fd);
if (ret < 0)
- return -1;
+ goto err;
fclose(fd);
copy_descr_attr(dev, &descr, bDeviceClass);
@@ -124,6 +124,9 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev)
name = udev_device_get_sysname(plat);
strncpy(dev->busid, name, SYSFS_BUS_ID_SIZE);
return 0;
+err:
+ fclose(fd);
+ return -1;
}
static int is_my_device(struct udev_device *dev)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* tools: usb: usbip: fix fd leak in case of 'fread' failure
@ 2018-01-02 17:48 Shuah Khan
0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2018-01-02 17:48 UTC (permalink / raw)
To: Elad Wexler, valentina.manea.m, Shuah Khan
Cc: linux-usb, linux-kernel, Greg Kroah-Hartman, Shuah Khan
On 12/30/2017 09:01 AM, Elad Wexler wrote:
> Fix possible resource leak: fd
>
> Signed-off-by: Elad Wexler <elad.wexler@gmail.com>
Thanks for the patch. Looks good to me.
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Greg, please pick this patch up.
thanks,
-- Shuah
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-02 17:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-30 16:01 tools: usb: usbip: fix fd leak in case of 'fread' failure Elad Wexler
-- strict thread matches above, loose matches on Subject: below --
2018-01-02 17:48 Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).