* [PATCH 0/7] HID: asus: increase robustness of the driver
@ 2026-02-28 14:46 Denis Benato
2026-02-28 14:46 ` [PATCH 1/7] HID: asus: fix code style of comments and brackets Denis Benato
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Denis Benato @ 2026-02-28 14:46 UTC (permalink / raw)
To: linux-kernel
Cc: linux-input, Benjamin Tissoires, Jiri Kosina, Luke D . Jones,
Mateusz Schyboll, Denis Benato, Denis Benato
Hi all,
Previous asus-wmi maintainer and asus-linux developer has become less
active in the project and left me in charge of advancing the support
for ASUS equipement on Linux.
I am preparing to send a patchset of his revised work to support ASUS
ROG Ally handhelds devices and since that work is also useful in
expanding support for 2025 models it is important to improve the
hid-asus driver as future patches will build on top of these changes.
Cheers,
Denis
Denis Benato (7):
HID: asus: fix code style of comments and brackets
HID: asus: add xg mobile 2022 external hardware support
HID: asus: fix compiler warning about unused variables
HID: asus: make asus_resume adhere to linux kernel coding standards
HID: asus: simplify and improve asus_kbd_set_report()
HID: asus: do not abort probe when not necessary
HID: asus: do not try to initialize the backlight if the enpoint
doesn't support it
drivers/hid/hid-asus.c | 67 ++++++++++++++++++------------------------
drivers/hid/hid-ids.h | 1 +
2 files changed, 29 insertions(+), 39 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/7] HID: asus: fix code style of comments and brackets
2026-02-28 14:46 [PATCH 0/7] HID: asus: increase robustness of the driver Denis Benato
@ 2026-02-28 14:46 ` Denis Benato
2026-02-28 14:46 ` [PATCH 2/7] HID: asus: add xg mobile 2022 external hardware support Denis Benato
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Denis Benato @ 2026-02-28 14:46 UTC (permalink / raw)
To: linux-kernel
Cc: linux-input, Benjamin Tissoires, Jiri Kosina, Luke D . Jones,
Mateusz Schyboll, Denis Benato, Denis Benato
In asus_raw_event there is code that would violate checkpatch script
such as unaligned closing comments and superfluous graph parenthesis:
fix these stylistic issues.
Also remove an empty comment spanning two lines.
This commit does not change runtime behavior.
Signed-off-by: Denis Benato <denis.benato@linux.dev>
---
drivers/hid/hid-asus.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index ffbfaff9f117..5fcb06b16167 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -20,9 +20,6 @@
* Copyright (c) 2016 Frederik Wenigwieser <frederik.wenigwieser@gmail.com>
*/
-/*
- */
-
#include <linux/acpi.h>
#include <linux/dmi.h>
#include <linux/hid.h>
@@ -359,7 +356,7 @@ static int asus_event(struct hid_device *hdev, struct hid_field *field,
struct hid_usage *usage, __s32 value)
{
struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
-
+
if ((usage->hid & HID_USAGE_PAGE) == HID_UP_ASUSVENDOR &&
(usage->hid & HID_USAGE) != 0x00 &&
(usage->hid & HID_USAGE) != 0xff && !usage->type) {
@@ -448,21 +445,18 @@ static int asus_raw_event(struct hid_device *hdev,
/*
* G713 and G733 send these codes on some keypresses, depending on
* the key pressed it can trigger a shutdown event if not caught.
- */
- if (data[0] == 0x02 && data[1] == 0x30) {
+ */
+ if (data[0] == 0x02 && data[1] == 0x30)
return -1;
- }
}
if (drvdata->quirks & QUIRK_ROG_CLAYMORE_II_KEYBOARD) {
/*
* CLAYMORE II keyboard sends this packet when it goes to sleep
* this causes the whole system to go into suspend.
- */
-
- if(size == 2 && data[0] == 0x02 && data[1] == 0x00) {
+ */
+ if (size == 2 && data[0] == 0x02 && data[1] == 0x00)
return -1;
- }
}
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/7] HID: asus: add xg mobile 2022 external hardware support
2026-02-28 14:46 [PATCH 0/7] HID: asus: increase robustness of the driver Denis Benato
2026-02-28 14:46 ` [PATCH 1/7] HID: asus: fix code style of comments and brackets Denis Benato
@ 2026-02-28 14:46 ` Denis Benato
2026-02-28 14:46 ` [PATCH 3/7] HID: asus: fix compiler warning about unused variables Denis Benato
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Denis Benato @ 2026-02-28 14:46 UTC (permalink / raw)
To: linux-kernel
Cc: linux-input, Benjamin Tissoires, Jiri Kosina, Luke D . Jones,
Mateusz Schyboll, Denis Benato, Denis Benato
XG mobile station 2022 has a different PID than the 2023 model: add it
that model to hid-asus.
Signed-off-by: Denis Benato <denis.benato@linux.dev>
---
drivers/hid/hid-asus.c | 3 +++
drivers/hid/hid-ids.h | 1 +
2 files changed, 4 insertions(+)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 5fcb06b16167..fbcf38b15290 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -1515,6 +1515,9 @@ static const struct hid_device_id asus_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X),
QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD | QUIRK_ROG_ALLY_XPAD },
+ { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
+ USB_DEVICE_ID_ASUSTEK_XGM_2022),
+ },
{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
USB_DEVICE_ID_ASUSTEK_XGM_2023),
},
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 4ab7640b119a..5e85921049e0 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -229,6 +229,7 @@
#define USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X 0x1b4c
#define USB_DEVICE_ID_ASUSTEK_ROG_CLAYMORE_II_KEYBOARD 0x196b
#define USB_DEVICE_ID_ASUSTEK_FX503VD_KEYBOARD 0x1869
+#define USB_DEVICE_ID_ASUSTEK_XGM_2022 0x1970
#define USB_DEVICE_ID_ASUSTEK_XGM_2023 0x1a9a
#define USB_VENDOR_ID_ATEN 0x0557
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/7] HID: asus: fix compiler warning about unused variables
2026-02-28 14:46 [PATCH 0/7] HID: asus: increase robustness of the driver Denis Benato
2026-02-28 14:46 ` [PATCH 1/7] HID: asus: fix code style of comments and brackets Denis Benato
2026-02-28 14:46 ` [PATCH 2/7] HID: asus: add xg mobile 2022 external hardware support Denis Benato
@ 2026-02-28 14:46 ` Denis Benato
2026-02-28 14:46 ` [PATCH 4/7] HID: asus: make asus_resume adhere to linux kernel coding standards Denis Benato
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Denis Benato @ 2026-02-28 14:46 UTC (permalink / raw)
To: linux-kernel
Cc: linux-input, Benjamin Tissoires, Jiri Kosina, Luke D . Jones,
Mateusz Schyboll, Denis Benato, Denis Benato
In the function asus_has_report_id there are 3 unused variables clang
warns about: remove them.
Fixes:0919db9f3583 ("HID: asus: always fully initialize devices")
Signed-off-by: Denis Benato <denis.benato@linux.dev>
---
drivers/hid/hid-asus.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index fbcf38b15290..2b4411399571 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -723,10 +723,9 @@ static void validate_mcu_fw_version(struct hid_device *hdev, int idProduct)
static bool asus_has_report_id(struct hid_device *hdev, u16 report_id)
{
- int t, f, u, err = 0;
struct hid_report *report;
- for (t = HID_INPUT_REPORT; t <= HID_FEATURE_REPORT; t++) {
+ for (int t = HID_INPUT_REPORT; t <= HID_FEATURE_REPORT; t++) {
list_for_each_entry(report, &hdev->report_enum[t].report_list, list) {
if (report->id == report_id)
return true;
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/7] HID: asus: make asus_resume adhere to linux kernel coding standards
2026-02-28 14:46 [PATCH 0/7] HID: asus: increase robustness of the driver Denis Benato
` (2 preceding siblings ...)
2026-02-28 14:46 ` [PATCH 3/7] HID: asus: fix compiler warning about unused variables Denis Benato
@ 2026-02-28 14:46 ` Denis Benato
2026-02-28 14:46 ` [PATCH 5/7] HID: asus: simplify and improve asus_kbd_set_report() Denis Benato
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Denis Benato @ 2026-02-28 14:46 UTC (permalink / raw)
To: linux-kernel
Cc: linux-input, Benjamin Tissoires, Jiri Kosina, Luke D . Jones,
Mateusz Schyboll, Denis Benato, Denis Benato
Linux kernel coding standars requires functions opening brackets to be in
a newline: move the opening bracket of asus_resume in its own line.
Fixes: 546edbd26cff ("HID: hid-asus: reset the backlight brightness level on resume")
Signed-off-by: Denis Benato <denis.benato@linux.dev>
---
drivers/hid/hid-asus.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 2b4411399571..48731b48523d 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -1171,7 +1171,8 @@ static int asus_start_multitouch(struct hid_device *hdev)
return 0;
}
-static int __maybe_unused asus_resume(struct hid_device *hdev) {
+static int __maybe_unused asus_resume(struct hid_device *hdev)
+{
struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
int ret = 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/7] HID: asus: simplify and improve asus_kbd_set_report()
2026-02-28 14:46 [PATCH 0/7] HID: asus: increase robustness of the driver Denis Benato
` (3 preceding siblings ...)
2026-02-28 14:46 ` [PATCH 4/7] HID: asus: make asus_resume adhere to linux kernel coding standards Denis Benato
@ 2026-02-28 14:46 ` Denis Benato
2026-02-28 14:46 ` [PATCH 6/7] HID: asus: do not abort probe when not necessary Denis Benato
2026-02-28 14:46 ` [PATCH 7/7] HID: asus: do not try to initialize the backlight if the enpoint doesn't support it Denis Benato
6 siblings, 0 replies; 8+ messages in thread
From: Denis Benato @ 2026-02-28 14:46 UTC (permalink / raw)
To: linux-kernel
Cc: linux-input, Benjamin Tissoires, Jiri Kosina, Luke D . Jones,
Mateusz Schyboll, Denis Benato, Denis Benato
Make the function shorter and easier to read using __free, and also fix a
misaligned comment closing tag.
The __free macro from cleanup.h is already used in the driver, but its
include is missing: add it.
Signed-off-by: Denis Benato <denis.benato@linux.dev>
---
drivers/hid/hid-asus.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 48731b48523d..61705fd10d90 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -21,6 +21,7 @@
*/
#include <linux/acpi.h>
+#include <linux/cleanup.h>
#include <linux/dmi.h>
#include <linux/hid.h>
#include <linux/module.h>
@@ -464,23 +465,18 @@ static int asus_raw_event(struct hid_device *hdev,
static int asus_kbd_set_report(struct hid_device *hdev, const u8 *buf, size_t buf_size)
{
- unsigned char *dmabuf;
int ret;
- dmabuf = kmemdup(buf, buf_size, GFP_KERNEL);
+ u8 *dmabuf __free(kfree) = kmemdup(buf, buf_size, GFP_KERNEL);
if (!dmabuf)
return -ENOMEM;
/*
* The report ID should be set from the incoming buffer due to LED and key
* interfaces having different pages
- */
- ret = hid_hw_raw_request(hdev, buf[0], dmabuf,
- buf_size, HID_FEATURE_REPORT,
- HID_REQ_SET_REPORT);
- kfree(dmabuf);
-
- return ret;
+ */
+ return hid_hw_raw_request(hdev, buf[0], dmabuf, buf_size, HID_FEATURE_REPORT,
+ HID_REQ_SET_REPORT);
}
static int asus_kbd_init(struct hid_device *hdev, u8 report_id)
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/7] HID: asus: do not abort probe when not necessary
2026-02-28 14:46 [PATCH 0/7] HID: asus: increase robustness of the driver Denis Benato
` (4 preceding siblings ...)
2026-02-28 14:46 ` [PATCH 5/7] HID: asus: simplify and improve asus_kbd_set_report() Denis Benato
@ 2026-02-28 14:46 ` Denis Benato
2026-02-28 14:46 ` [PATCH 7/7] HID: asus: do not try to initialize the backlight if the enpoint doesn't support it Denis Benato
6 siblings, 0 replies; 8+ messages in thread
From: Denis Benato @ 2026-02-28 14:46 UTC (permalink / raw)
To: linux-kernel
Cc: linux-input, Benjamin Tissoires, Jiri Kosina, Luke D . Jones,
Mateusz Schyboll, Denis Benato, Denis Benato
In order to avoid dereferencing a NULL pointer asus_probe is aborted early
and control of some asus devices is transferred over hid-generic after
erroring out even when such NULL dereference cannot happen: only early
abort when the NULL dereference can happen.
Also make the code shorter and more adherent to coding standards
removing square brackets enclosing single-line if-else statements.
Fixes: d3af6ca9a8c3 ("HID: asus: fix UAF via HID_CLAIMED_INPUT validation")
Signed-off-by: Denis Benato <denis.benato@linux.dev>
---
drivers/hid/hid-asus.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 61705fd10d90..bcf3b0c7c758 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -1325,22 +1325,17 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
* were freed during registration due to no usages being mapped,
* leaving drvdata->input pointing to freed memory.
*/
- if (!drvdata->input || !(hdev->claimed & HID_CLAIMED_INPUT)) {
- hid_err(hdev, "Asus input not registered\n");
- ret = -ENOMEM;
- goto err_stop_hw;
- }
-
- if (drvdata->tp) {
- drvdata->input->name = "Asus TouchPad";
- } else {
- drvdata->input->name = "Asus Keyboard";
- }
+ if (drvdata->input && (hdev->claimed & HID_CLAIMED_INPUT)) {
+ if (drvdata->tp)
+ drvdata->input->name = "Asus TouchPad";
+ else
+ drvdata->input->name = "Asus Keyboard";
- if (drvdata->tp) {
- ret = asus_start_multitouch(hdev);
- if (ret)
- goto err_stop_hw;
+ if (drvdata->tp) {
+ ret = asus_start_multitouch(hdev);
+ if (ret)
+ goto err_stop_hw;
+ }
}
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 7/7] HID: asus: do not try to initialize the backlight if the enpoint doesn't support it
2026-02-28 14:46 [PATCH 0/7] HID: asus: increase robustness of the driver Denis Benato
` (5 preceding siblings ...)
2026-02-28 14:46 ` [PATCH 6/7] HID: asus: do not abort probe when not necessary Denis Benato
@ 2026-02-28 14:46 ` Denis Benato
6 siblings, 0 replies; 8+ messages in thread
From: Denis Benato @ 2026-02-28 14:46 UTC (permalink / raw)
To: linux-kernel
Cc: linux-input, Benjamin Tissoires, Jiri Kosina, Luke D . Jones,
Mateusz Schyboll, Denis Benato, Denis Benato
Avoid possibly printing a warning about the inability to initialize the
backlight if the hid endpoint doesn't support it.
Signed-off-by: Denis Benato <denis.benato@linux.dev>
---
drivers/hid/hid-asus.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index bcf3b0c7c758..6e9a3a3d5616 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -1309,7 +1309,8 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
}
if (is_vendor && (drvdata->quirks & QUIRK_USE_KBD_BACKLIGHT) &&
- asus_kbd_register_leds(hdev))
+ (asus_has_report_id(hdev, FEATURE_KBD_REPORT_ID)) &&
+ (asus_kbd_register_leds(hdev)))
hid_warn(hdev, "Failed to initialize backlight.\n");
/*
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-02-28 14:46 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-28 14:46 [PATCH 0/7] HID: asus: increase robustness of the driver Denis Benato
2026-02-28 14:46 ` [PATCH 1/7] HID: asus: fix code style of comments and brackets Denis Benato
2026-02-28 14:46 ` [PATCH 2/7] HID: asus: add xg mobile 2022 external hardware support Denis Benato
2026-02-28 14:46 ` [PATCH 3/7] HID: asus: fix compiler warning about unused variables Denis Benato
2026-02-28 14:46 ` [PATCH 4/7] HID: asus: make asus_resume adhere to linux kernel coding standards Denis Benato
2026-02-28 14:46 ` [PATCH 5/7] HID: asus: simplify and improve asus_kbd_set_report() Denis Benato
2026-02-28 14:46 ` [PATCH 6/7] HID: asus: do not abort probe when not necessary Denis Benato
2026-02-28 14:46 ` [PATCH 7/7] HID: asus: do not try to initialize the backlight if the enpoint doesn't support it Denis Benato
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox