diff options
author | GwanYeong Kim <gy741.kim@gmail.com> | 2019-10-18 03:22:23 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-11-12 19:21:09 +0100 |
commit | e36be7959326f3b49653e64f46612ca6a5b98fd2 (patch) | |
tree | 20d61f77184f375b6b162c6f17036765c7f814c2 /tools | |
parent | cd9561a53d263745f48768e23b02d08bdde1c5b3 (diff) | |
download | linux-stable-e36be7959326f3b49653e64f46612ca6a5b98fd2.tar.gz linux-stable-e36be7959326f3b49653e64f46612ca6a5b98fd2.tar.bz2 linux-stable-e36be7959326f3b49653e64f46612ca6a5b98fd2.zip |
usbip: tools: Fix read_usb_vudc_device() error path handling
[ Upstream commit 28df0642abbf6d66908a2858922a7e4b21cdd8c2 ]
This isn't really accurate right. fread() doesn't always
return 0 in error. It could return < number of elements
and set errno.
Signed-off-by: GwanYeong Kim <gy741.kim@gmail.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20191018032223.4644-1-gy741.kim@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/usb/usbip/libsrc/usbip_device_driver.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/usb/usbip/libsrc/usbip_device_driver.c b/tools/usb/usbip/libsrc/usbip_device_driver.c index ec3a0b794f15..67ae6c1557b8 100644 --- a/tools/usb/usbip/libsrc/usbip_device_driver.c +++ b/tools/usb/usbip/libsrc/usbip_device_driver.c @@ -81,7 +81,7 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev) FILE *fd = NULL; struct udev_device *plat; const char *speed; - int ret = 0; + size_t ret; plat = udev_device_get_parent(sdev); path = udev_device_get_syspath(plat); @@ -91,8 +91,10 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev) if (!fd) return -1; ret = fread((char *) &descr, sizeof(descr), 1, fd); - if (ret < 0) + if (ret != 1) { + err("Cannot read vudc device descr file: %s", strerror(errno)); goto err; + } fclose(fd); copy_descr_attr(dev, &descr, bDeviceClass); |