Commit 5b1e5be8 authored by Andries E. Brouwer's avatar Andries E. Brouwer Committed by Greg Kroah-Hartman

[PATCH] usb_string fix

Things are indeed as conjectured, and I can reproduce the situation
where usb_string() returns -EPIPE. Now that this is an internal
error code for the USB subsystem, and not meant to get out to the
user, I made these driverfs files empty in case of error.
(While if there is no error but the string has length 0,
the file will consist of a single '\n'.)

One fewer random memory corruption. Unfortunately, there are more.

Andries
parent 188482b7
...@@ -864,8 +864,10 @@ static ssize_t show_product (struct device *dev, char *buf, size_t count, loff_t ...@@ -864,8 +864,10 @@ static ssize_t show_product (struct device *dev, char *buf, size_t count, loff_t
udev = to_usb_device (dev); udev = to_usb_device (dev);
len = usb_string(udev, udev->descriptor.iProduct, buf, PAGE_SIZE); len = usb_string(udev, udev->descriptor.iProduct, buf, PAGE_SIZE);
if (len < 0)
return 0;
buf[len] = '\n'; buf[len] = '\n';
buf[len+1] = 0x00; buf[len+1] = 0;
return len+1; return len+1;
} }
static DEVICE_ATTR(product,"product",S_IRUGO,show_product,NULL); static DEVICE_ATTR(product,"product",S_IRUGO,show_product,NULL);
...@@ -882,8 +884,10 @@ show_manufacturer (struct device *dev, char *buf, size_t count, loff_t off) ...@@ -882,8 +884,10 @@ show_manufacturer (struct device *dev, char *buf, size_t count, loff_t off)
udev = to_usb_device (dev); udev = to_usb_device (dev);
len = usb_string(udev, udev->descriptor.iManufacturer, buf, PAGE_SIZE); len = usb_string(udev, udev->descriptor.iManufacturer, buf, PAGE_SIZE);
if (len < 0)
return 0;
buf[len] = '\n'; buf[len] = '\n';
buf[len+1] = 0x00; buf[len+1] = 0;
return len+1; return len+1;
} }
static DEVICE_ATTR(manufacturer,"manufacturer",S_IRUGO,show_manufacturer,NULL); static DEVICE_ATTR(manufacturer,"manufacturer",S_IRUGO,show_manufacturer,NULL);
...@@ -900,8 +904,10 @@ show_serial (struct device *dev, char *buf, size_t count, loff_t off) ...@@ -900,8 +904,10 @@ show_serial (struct device *dev, char *buf, size_t count, loff_t off)
udev = to_usb_device (dev); udev = to_usb_device (dev);
len = usb_string(udev, udev->descriptor.iSerialNumber, buf, PAGE_SIZE); len = usb_string(udev, udev->descriptor.iSerialNumber, buf, PAGE_SIZE);
if (len < 0)
return 0;
buf[len] = '\n'; buf[len] = '\n';
buf[len+1] = 0x00; buf[len+1] = 0;
return len+1; return len+1;
} }
static DEVICE_ATTR(serial,"serial",S_IRUGO,show_serial,NULL); static DEVICE_ATTR(serial,"serial",S_IRUGO,show_serial,NULL);
...@@ -918,7 +924,7 @@ static void usb_find_drivers(struct usb_device *dev) ...@@ -918,7 +924,7 @@ static void usb_find_drivers(struct usb_device *dev)
unsigned claimed = 0; unsigned claimed = 0;
/* FIXME should get called for each new configuration not just the /* FIXME should get called for each new configuration not just the
* first one for a device. switching configs (or altesettings) should * first one for a device. switching configs (or altsettings) should
* undo driverfs and HCD state for the previous interfaces. * undo driverfs and HCD state for the previous interfaces.
*/ */
for (ifnum = 0; ifnum < dev->actconfig->bNumInterfaces; ifnum++) { for (ifnum = 0; ifnum < dev->actconfig->bNumInterfaces; ifnum++) {
......
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