From: Elad Wexler <elad.wexler@gmail.com>
To: valentina.manea.m@gmail.com, shuah@kernel.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: tools: usb: usbip: fix fd leak in case of 'fread' failure
Date: Sat, 30 Dec 2017 18:01:39 +0200 [thread overview]
Message-ID: <20171230160139.GA9741@ewexler> (raw)
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)
next reply other threads:[~2017-12-30 16:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-30 16:01 Elad Wexler [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-01-02 17:48 tools: usb: usbip: fix fd leak in case of 'fread' failure Shuah Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171230160139.GA9741@ewexler \
--to=elad.wexler@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=valentina.manea.m@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).