public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: John Mock <kd6pag@qsl.net>
Cc: linux-kernel@vger.kernel.org, greg@kroah.com
Subject: Re: 2.6.11-rc1 vs. PowerMac 8500/G3 (and VAIO laptop) [usb-storage oops]
Date: Thu, 20 Jan 2005 08:40:07 +0000	[thread overview]
Message-ID: <1106210408.6932.27.camel@localhost.localdomain> (raw)
In-Reply-To: <E1CrPQ4-0000pW-00@penngrove.fdns.net>

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


  reply	other threads:[~2005-01-20  8:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-19 23:39 2.6.11-rc1 vs. PowerMac 8500/G3 (and VAIO laptop) [usb-storage oops] John Mock
2005-01-20  8:40 ` David Woodhouse [this message]
2005-01-21  0:08   ` Greg KH
2005-01-21  7:49     ` David Woodhouse
2005-01-21  7:58       ` Greg KH
2005-01-21  8:12         ` David Woodhouse
2005-01-21  8:42           ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2005-01-20 18:29 John Mock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1106210408.6932.27.camel@localhost.localdomain \
    --to=dwmw2@infradead.org \
    --cc=greg@kroah.com \
    --cc=kd6pag@qsl.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox