Re: 2.6.11-rc1 vs. PowerMac 8500/G3 (and VAIO laptop) [usb-storageoops]

From: David Woodhouse
Date: Thu Jan 20 2005 - 03:45:05 EST


On Wed, 2005-01-19 at 15:39 -0800, John Mock wrote:
> New to 2.6.11-rc1 is that 'lsusb' exhibits 'endian' problems on the
> PowerMac.

Is that really new to 2.6.11-rc1? The kernel byte-swaps the bcdUSB,
idVendor, idProduct, and bcdDevice fields in the device descriptor. It
should probably swap them back before copying it up to userspace.

===== drivers/usb/core/devio.c 1.93 vs edited =====
--- 1.93/drivers/usb/core/devio.c 2004-12-16 23:35:55 +00:00
+++ edited/drivers/usb/core/devio.c 2005-01-20 08:33:50 +00:00
@@ -123,13 +123,26 @@
}

if (pos < sizeof(struct usb_device_descriptor)) {
+ struct usb_device_descriptor *desc = kmalloc(sizeof(*desc), GFP_KERNEL);
+ if (!desc) {
+ ret = -ENOMEM;
+ goto err;
+ }
+ memcpy(desc, &dev->descriptor, sizeof(dev->descriptor));
+ le16_to_cpus(&desc->bcdUSB);
+ le16_to_cpus(&desc->idVendor);
+ le16_to_cpus(&desc->idProduct);
+ le16_to_cpus(&desc->bcdDevice);
+
len = sizeof(struct usb_device_descriptor) - pos;
if (len > nbytes)
len = nbytes;
- if (copy_to_user(buf, ((char *)&dev->descriptor) + pos, len)) {
+ if (copy_to_user(buf, ((char *)desc) + pos, len)) {
+ kfree(desc);
ret = -EFAULT;
goto err;
}
+ kfree(desc);

*ppos += len;
buf += len;


--
dwmw2

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/