ChangeSet 1.2043, 2005/02/03 01:38:05-08:00, [EMAIL PROTECTED] [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 <[EMAIL PROTECTED]> Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]> drivers/usb/core/devio.c | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletion(-) diff -Nru a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c --- a/drivers/usb/core/devio.c 2005-02-03 08:45:19 -08:00 +++ b/drivers/usb/core/devio.c 2005-02-03 08:45:19 -08: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; ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel