Commit 630d2acc authored by David Woodhouse's avatar David Woodhouse Committed by Greg Kroah-Hartman

[PATCH] USB: fix libusb endian issues

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.

From: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 7d4e3289
......@@ -123,13 +123,26 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, l
}
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;
......
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