Thread (4 messages) 4 messages, 3 authors, 2021-06-21

Re: [PATCH] usb: gadget: f_hid: fix endianness issue with descriptors

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: 2021-06-17 16:52:59
Also in: lkml

On Thu, Jun 17, 2021 at 07:27:55PM +0300, Ruslan Bilovol wrote:
quoted hunk ↗ jump to hunk
Running sparse checker it shows warning message about
incorrect endianness used for descriptor initialization:

| f_hid.c:91:43: warning: incorrect type in initializer (different base types)
| f_hid.c:91:43:    expected restricted __le16 [usertype] bcdHID
| f_hid.c:91:43:    got int

Fixing issue with cpu_to_le16() macro

Fixes: 71adf1189469 ("USB: gadget: add HID gadget driver")
Cc: Fabien Chouteau <redacted>
Cc: Segiy Stetsyuk <redacted>
Cc: stable@kernel.org
Signed-off-by: Ruslan Bilovol <redacted>
---
 drivers/usb/gadget/function/f_hid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index 70774d8cb14e..02683ac0719d 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -88,7 +88,7 @@ static struct usb_interface_descriptor hidg_interface_desc = {
 static struct hid_descriptor hidg_desc = {
 	.bLength			= sizeof hidg_desc,
 	.bDescriptorType		= HID_DT_HID,
-	.bcdHID				= 0x0101,
+	.bcdHID				= cpu_to_le16(0x0101),
This is a BCD value, not a little-endian value, are you sure this
conversion is correct?

thanks,

greg k-h
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help