[PATCH 4/6] usb: string: Use le16_to_cpu for langid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This might fix an endianness bug when the cpu is big-endian
as the string_langid will be converted with `cpu_to_le16` when
sending a control message to get a string descriptor.

Signed-off-by: Jules Maselbas <jmaselbas@xxxxxxxxx>
---
 drivers/usb/core/usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index e14b89b5e..5dc7993ac 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -925,7 +925,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
 			goto error;
 		} else {
 			dev->have_langid = -1;
-			dev->string_langid = tbuf[2] | (tbuf[3] << 8);
+			dev->string_langid = le16_to_cpu(*((__le16 *)&buf[2]));
 				/* always use the first langid listed */
 			pr_debug("USB device number %d default " \
 				   "language ID 0x%x\n",
-- 
2.21.0.196.g041f5ea


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux