Skip to contentSkip to conversation

Fix USB vendor and product IDs endianness for USB HID devices

PATCH In review Julien BLACHE 2 participants 3 messages Feb 10, 2007 – Feb 11, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix USB vendor and product IDs endianness for USB HID devices

Hi,

The generic HID layer changes introduced an endianness bug for USB HID devices.

The USB vendor and product IDs are not byteswapped appropriately, and thus come out in the wrong endianness when fetched through the evdev using ioctl() on big endian platforms.

This byteswapping used to be done in hidinput_connect() (by usb_to_input_id()) when filling up the hid device structure, and now needs to be done upstream. USB is the only user so far, and the hid_device structure is set up in usb_hid_configure().

hid-core.c renamed from hid-core.c~ +2 -2
@@ -1220,8 +1220,8 @@
 			 le16_to_cpu(dev->descriptor.idProduct));
 
 	hid->bus = BUS_USB;
-	hid->vendor = dev->descriptor.idVendor;
-	hid->product = dev->descriptor.idProduct;
+	hid->vendor = le16_to_cpu(dev->descriptor.idVendor);
+	hid->product = le16_to_cpu(dev->descriptor.idProduct);
 
 	usb_make_path(dev, hid->phys, sizeof(hid->phys));
 	strlcat(hid->phys, "/input", sizeof(hid->phys));

Please apply, and this is a candidate for -stable as it breaks a documented API/ABI in userspace.

JB.

Signature · 2 lines
Julien BLACHE                                   <http://www.jblache.org> 
<[email protected]>                                  GPG KeyID 0xF5D65169
#1 lore raw
Quoted 2 lines · Julien BLACHE

The generic HID layer changes introduced an endianness bug for USB HID devices.

Hi Julien,

this is obviously a bug, thanks for a fix, I queued it for upstream.

Two nitpicks:

- could you please submitpatches in standard conventions, so that they could be applied directly using patch -p1 against toplevel of the kernel tree (your patch was just against hid-core.c, but without any path)
- please inline patches in message and do not attach them, if possible

I will submit the patch to stable team.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs
#2 lore raw

Jiri Kosina <[email protected]> wrote:

Hi,

Quoted 1 line

this is obviously a bug, thanks for a fix, I queued it for upstream.

Thanks.

Quoted 5 lines

Two nitpicks:

- could you please submitpatches in standard conventions, so that they could be applied directly using patch -p1 against toplevel of the kernel tree (your patch was just against hid-core.c, but without any path)

Gah, I did that again. Sorry.

Quoted 1 line

- please inline patches in message and do not attach them, if possible

Same here, got fooled again into doing an inline MIME part instead of inlining the patch for real.

JB.

Signature · 2 lines
Julien BLACHE                                   <http://www.jblache.org> 
<[email protected]>                                  GPG KeyID 0xF5D65169