The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 0/3] hid: fix missing hid_is_usb() checks in three drivers
@ 2026-07-03 15:16 Jann Horn
  2026-07-03 15:16 ` [PATCH 1/3] HID: asus: fix missing hid_is_usb() check Jann Horn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jann Horn @ 2026-07-03 15:16 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires
  Cc: Ilpo Järvinen, Mario Limonciello, Luke D. Jones, Miao Li,
	linux-input, linux-kernel, Jann Horn, stable

This fixes missing hid_is_usb() checks before to_usb_interface() in
three HID drivers.
I've split it into three patches so that they can have separate "Fixes"
tags, hopefully they are easier to stable-backport this way.

Signed-off-by: Jann Horn <jannh@google.com>
---
Jann Horn (3):
      HID: asus: fix missing hid_is_usb() check
      HID: huawei: fix missing hid_is_usb() check
      HID: rapoo: fix missing hid_is_usb() check

 drivers/hid/hid-asus.c   | 2 +-
 drivers/hid/hid-huawei.c | 5 +++--
 drivers/hid/hid-rapoo.c  | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)
---
base-commit: 51512e22efe813d8223de27f6fd02a8a48ea2323
change-id: 20260703-hid-usbcheck-9163e6cf6015

Best regards,
--  
Jann Horn <jannh@google.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] HID: asus: fix missing hid_is_usb() check
  2026-07-03 15:16 [PATCH 0/3] hid: fix missing hid_is_usb() checks in three drivers Jann Horn
@ 2026-07-03 15:16 ` Jann Horn
  2026-07-03 15:16 ` [PATCH 2/3] HID: huawei: " Jann Horn
  2026-07-03 15:16 ` [PATCH 3/3] HID: rapoo: " Jann Horn
  2 siblings, 0 replies; 4+ messages in thread
From: Jann Horn @ 2026-07-03 15:16 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires
  Cc: Ilpo Järvinen, Mario Limonciello, Luke D. Jones, Miao Li,
	linux-input, linux-kernel, Jann Horn, stable

to_usb_interface() can only be used on a hid_device whose parent is really
USB; uhid can create devices that identify as being on BUS_USB, but don't
actually have a USB parent.
Fix the use of to_usb_interface() without a hid_is_usb() check.

I have verified that it is currently possible to trigger a kernel splat due
to this bug in an ASAN build, and that this commit fixes the issue.

Fixes: 00e005c952f7 ("hid-asus: check ROG Ally MCU version and warn")
Cc: stable@vger.kernel.org
Signed-off-by: Jann Horn <jannh@google.com>
---
 drivers/hid/hid-asus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 3f5e96900b67..befa990b3210 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -753,7 +753,7 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
 			return ret;
 	}
 
-	if (drvdata->quirks & QUIRK_ROG_ALLY_XPAD) {
+	if ((drvdata->quirks & QUIRK_ROG_ALLY_XPAD) && hid_is_usb(hdev)) {
 		intf = to_usb_interface(hdev->dev.parent);
 		udev = interface_to_usbdev(intf);
 		validate_mcu_fw_version(hdev,

-- 
2.55.0.rc0.799.gd6f94ed593-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] HID: huawei: fix missing hid_is_usb() check
  2026-07-03 15:16 [PATCH 0/3] hid: fix missing hid_is_usb() checks in three drivers Jann Horn
  2026-07-03 15:16 ` [PATCH 1/3] HID: asus: fix missing hid_is_usb() check Jann Horn
@ 2026-07-03 15:16 ` Jann Horn
  2026-07-03 15:16 ` [PATCH 3/3] HID: rapoo: " Jann Horn
  2 siblings, 0 replies; 4+ messages in thread
From: Jann Horn @ 2026-07-03 15:16 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires
  Cc: Ilpo Järvinen, Mario Limonciello, Luke D. Jones, Miao Li,
	linux-input, linux-kernel, Jann Horn, stable

to_usb_interface() can only be used on a hid_device whose parent is really
USB; uhid can create devices that identify as being on BUS_USB, but don't
actually have a USB parent.
Fix the use of to_usb_interface() without a hid_is_usb() check.

I have verified that it is currently possible to trigger a kernel splat due
to this bug in an ASAN build, and that this commit fixes the issue.

Fixes: e93faaca84b7 ("HID: huawei: fix CD30 keyboard report descriptor issue")
Cc: stable@vger.kernel.org
Signed-off-by: Jann Horn <jannh@google.com>
---
 drivers/hid/hid-huawei.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-huawei.c b/drivers/hid/hid-huawei.c
index 6a616bf21b38..ee3fc6f68475 100644
--- a/drivers/hid/hid-huawei.c
+++ b/drivers/hid/hid-huawei.c
@@ -44,11 +44,12 @@ static const __u8 huawei_cd30_kbd_rdesc_fixed[] = {
 static const __u8 *huawei_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 				  unsigned int *rsize)
 {
-	struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
+	struct usb_interface *intf = hid_is_usb(hdev) ?
+			to_usb_interface(hdev->dev.parent) : NULL;
 
 	switch (hdev->product) {
 	case USB_DEVICE_ID_HUAWEI_CD30KBD:
-		if (intf->cur_altsetting->desc.bInterfaceNumber == 1) {
+		if (!intf || intf->cur_altsetting->desc.bInterfaceNumber == 1) {
 			if (*rsize != sizeof(huawei_cd30_kbd_rdesc_fixed) ||
 				memcmp(huawei_cd30_kbd_rdesc_fixed, rdesc,
 					sizeof(huawei_cd30_kbd_rdesc_fixed)) != 0) {

-- 
2.55.0.rc0.799.gd6f94ed593-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] HID: rapoo: fix missing hid_is_usb() check
  2026-07-03 15:16 [PATCH 0/3] hid: fix missing hid_is_usb() checks in three drivers Jann Horn
  2026-07-03 15:16 ` [PATCH 1/3] HID: asus: fix missing hid_is_usb() check Jann Horn
  2026-07-03 15:16 ` [PATCH 2/3] HID: huawei: " Jann Horn
@ 2026-07-03 15:16 ` Jann Horn
  2 siblings, 0 replies; 4+ messages in thread
From: Jann Horn @ 2026-07-03 15:16 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires
  Cc: Ilpo Järvinen, Mario Limonciello, Luke D. Jones, Miao Li,
	linux-input, linux-kernel, Jann Horn, stable

to_usb_interface() can only be used on a hid_device whose parent is really
USB; uhid can create devices that identify as being on BUS_USB, but don't
actually have a USB parent.
Fix the use of to_usb_interface() without a hid_is_usb() check.

I have verified that it is currently possible to trigger a kernel splat due
to this bug in an ASAN build, and that this commit fixes the issue.

Fixes: 00e005c952f7 ("hid-asus: check ROG Ally MCU version and warn")Fixes: b3b1c68fb726 ("HID: rapoo: Add support for side buttons on RAPOO 0x2015 mouse")
Cc: stable@vger.kernel.org
Signed-off-by: Jann Horn <jannh@google.com>
---
 drivers/hid/hid-rapoo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-rapoo.c b/drivers/hid/hid-rapoo.c
index 4c81f3086de4..5c9c396fabf7 100644
--- a/drivers/hid/hid-rapoo.c
+++ b/drivers/hid/hid-rapoo.c
@@ -36,7 +36,7 @@ static int rapoo_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		return ret;
 	}
 
-	if (hdev->bus == BUS_USB) {
+	if (hid_is_usb(hdev)) {
 		struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
 
 		if (intf->cur_altsetting->desc.bInterfaceNumber != 1)

-- 
2.55.0.rc0.799.gd6f94ed593-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-03 15:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-03 15:16 [PATCH 0/3] hid: fix missing hid_is_usb() checks in three drivers Jann Horn
2026-07-03 15:16 ` [PATCH 1/3] HID: asus: fix missing hid_is_usb() check Jann Horn
2026-07-03 15:16 ` [PATCH 2/3] HID: huawei: " Jann Horn
2026-07-03 15:16 ` [PATCH 3/3] HID: rapoo: " Jann Horn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox