[PATCH v4 3/6] HID: wacom: add NULL input guards to wacom_intuos_irq() and its helpers
From: Jinmo Yang
Date: Fri Oct 23 2026 - 23:32:39 EST
wacom_intuos_irq() assigns pen_input to a local variable and
dereferences it in a dev_dbg() before any NULL check. Its helpers
wacom_intuos_inout() and wacom_intuos_general() also dereference
pen_input unconditionally. Add a pen_input NULL guard at the top of
wacom_intuos_irq() to protect them all.
wacom_intuos_pad() uses pad_input throughout, but pad_input can be NULL
when wacom_setup_pad_input_capabilities() returns -ENODEV during a
successful probe. Add a NULL guard after the report-ID check.
Adopt the same return convention as wacom_intuos_inout() and
wacom_intuos_general(): return 1 for "handled, don't sync" and 2 for
"handled, sync". Update wacom_intuos_irq() to apply the matching
"result - 1" transform so that the NULL-guard path (return 1) suppresses
the spurious input_sync() that the old "return 1" would have triggered
via wacom_wac_irq().
Fixes: 10059cdc0ad0 ("Input: wacom - split out the pad device for Intuos/Cintiq")
Signed-off-by: Jinmo Yang <jinmo44.yang@xxxxxxxxx>
Co-Authored-By: Claude Opus 4.6 <noreply@xxxxxxxxxxxxx>
---
drivers/hid/wacom_wac.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index bec8dbec5bc3..c38fbec114e4 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -581,6 +581,12 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
data[0] == WACOM_REPORT_CINTIQPAD))
return 0;
+ if (!input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: pad_input is NULL\n", __func__);
+ return 1; /* handled; the -1 in wacom_intuos_irq() suppresses sync */
+ }
+
if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
buttons = (data[3] << 1) | (data[2] & 0x01);
ring1 = data[1];
@@ -716,7 +722,7 @@ static int wacom_intuos_pad(struct wacom_wac *wacom)
input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
- return 1;
+ return 2;
}
static int wacom_intuos_id_mangle(int tool_id)
@@ -1073,6 +1079,12 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
struct input_dev *input = wacom->pen_input;
int result;
+ if (!input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: pen_input is NULL\n", __func__);
+ return 0;
+ }
+
if (data[0] != WACOM_REPORT_PENABLED &&
data[0] != WACOM_REPORT_INTUOS_ID1 &&
data[0] != WACOM_REPORT_INTUOS_ID2 &&
@@ -1089,7 +1101,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
/* process pad events */
result = wacom_intuos_pad(wacom);
if (result)
- return result;
+ return result - 1;
/* process in/out prox events */
result = wacom_intuos_inout(wacom);
--
2.53.0