* [PATCH v5 0/6] HID: wacom: guard against NULL input devices on successful probe
@ 2026-11-23 4:20 Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 1/6] HID: wacom: check the input device in the shared report helpers Jinmo Yang
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Jinmo Yang @ 2026-11-23 4:20 UTC (permalink / raw)
To: ping.cheng, jason.gerecke, jikos, bentiss
Cc: dmitry.torokhov, linux-input, linux-kernel, Jinmo Yang
When wacom_setup_{pen,touch,pad}_input_capabilities() returns -ENODEV,
the corresponding input pointer is set to NULL but probe still succeeds.
Subsequent irq handlers dereference those pointers unconditionally,
causing NULL-pointer dereferences reachable from a spoofed HID device.
This series adds per-function NULL guards across all affected handlers.
v4 was generated against a tree that predates commit 2f985de0afbe
("HID: wacom: fix wacom_intuos_irq NULL pen_input deref"), so patch 3/6
no longer applied and was dropped. This respin is against
hid.git#for-7.4/upstream-fixes (10bc1d627c29).
Jason's Reviewed-by from v4 is carried on the five patches that are
unchanged. It is not carried on 3/6, which was reworked.
Changes in v5:
- Rebased onto hid.git#for-7.4/upstream-fixes (Jiri).
- Reworked 3/6. Commit 2f985de0afbe removed the 'input' local and the
dev_dbg(input->dev.parent, ...) deref from wacom_intuos_irq(), so the
pen_input guard there now exists solely to protect
wacom_intuos_inout() and wacom_intuos_general(), which are its only
callers. The guard therefore reads wacom_wac->pen_input and uses the
struct wacom that 2f985de0afbe made a local, and it now sits below
the pad block rather than at the top of the function, so a device
with a valid pad but no pen keeps reporting pad events.
- No functional change to 1/6, 2/6, 4/6, 5/6 or 6/6.
Changes in v4:
- wacom_intuos_pad() now returns 2 for the normal path, 1 for the
NULL-guard path; wacom_intuos_irq() applies "result - 1" uniformly,
suppressing the spurious input_sync() the old "return 1" would
trigger (Jason).
- Added pen_input NULL guard at the top of wacom_intuos_irq() to
protect its helpers wacom_intuos_inout() and
wacom_intuos_general() (Jason).
- Added pen_input NULL guard to wacom_bpt_pen() (Jason).
Changes in v3:
- Fixed wacom_dtus_irq(): DTUSX is pen-only, so do not require
pad_input for it (sashiko-bot).
- Added patch 6: touch_input guards for wacom_intuos_pro2_bt_touch(),
wacom_24hdt_irq(), and wacom_bamboo_pad_touch_event().
Changes in v2:
- Restructured per Jason's review: per-function checks for dtus_irq,
graphire_irq, and the Bamboo handlers.
- wacom_intuos_pad() returns non-zero when pad_input is NULL so the
report does not fall through to wacom_intuos_inout() (sashiko-bot).
- wacom_intuos_bt_irq() guards both pen_input and pad_input (Jason).
- Added dev_warn_once at every guard (Jason).
- Dropped the cp2112 patch (Benjamin prefers Dmitry's series).
Jinmo Yang (6):
HID: wacom: check the input device in the shared report helpers
HID: wacom: check the input devices in the legacy irq handlers
HID: wacom: add NULL input guards to wacom_intuos_irq() and its
helpers
HID: wacom: add NULL input guards to wacom_intuos_bt_irq()
HID: wacom: add NULL input guards to Bamboo handlers
HID: wacom: add NULL touch_input guards to remaining touch handlers
drivers/hid/wacom_wac.c | 127 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 122 insertions(+), 5 deletions(-)
base-commit: 10bc1d627c297097cfdc099377f8a13efdfffd86
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v5 1/6] HID: wacom: check the input device in the shared report helpers
2026-11-23 4:20 [PATCH v5 0/6] HID: wacom: guard against NULL input devices on successful probe Jinmo Yang
@ 2026-11-23 4:20 ` Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 2/6] HID: wacom: check the input devices in the legacy irq handlers Jinmo Yang
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Jinmo Yang @ 2026-11-23 4:20 UTC (permalink / raw)
To: ping.cheng, jason.gerecke, jikos, bentiss
Cc: dmitry.torokhov, linux-input, linux-kernel, Jinmo Yang, stable
wacom_report_numbered_buttons() and wacom_wac_finger_count_touches() are
reached from several report handlers and use the input device they are
given without checking it.
Both can see a NULL input device on a fully successful probe. The report
handler is selected by features.type from the id table, while the three
input devices are allocated from what the report descriptor declares.
When wacom_setup_{pen,touch,pad}_input_capabilities() returns -ENODEV,
wacom_setup_inputs() frees that input device, sets the pointer to NULL
and still returns 0 - the "no pen in use on this interface" case.
wacom_wac_irq() then still routes reports to a handler that passes the
NULL pointer down.
Reproduced on linux-next 20260925 (x86_64, KASAN) from one /dev/uhid
device plus a single UHID_INPUT2 write:
BUG: KASAN: null-ptr-deref in range [0x290-0x297]
RIP: 0010:wacom_report_numbered_buttons+0x37/0x210
wacom_intuos_irq+0x29e/0x3300
wacom_wac_irq+0x1b59/0xb3f0
wacom_raw_event+0x68f/0xb60
__hid_input_report+0x398/0x4d0
uhid_char_write+0xa99/0xfc0
Check the pointer in both helpers, following the convention the driver
already uses in wacom_tpc_irq() and wacom_wac_pad_event(). Log a
warning on the first occurrence so the condition is not silently
swallowed.
Fixes: 10059cdc0ad0 ("Input: wacom - split out the pad device for Intuos/Cintiq")
Fixes: 2a6cdbdd4cc0 ("HID: wacom: Introduce new 'touch_input' device")
Cc: stable@vger.kernel.org
Signed-off-by: Jinmo Yang <jinmo44.yang@gmail.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
---
drivers/hid/wacom_wac.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index ab89a11d6740..c7bf0e5988e5 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1263,6 +1263,12 @@ static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
int count = 0;
int i;
+ if (!input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: touch_input is NULL\n", __func__);
+ return 0;
+ }
+
if (!touch_max)
return 0;
@@ -4254,9 +4260,16 @@ static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
static void wacom_report_numbered_buttons(struct input_dev *input_dev,
int button_count, int mask)
{
- struct wacom *wacom = input_get_drvdata(input_dev);
+ struct wacom *wacom;
int i;
+ if (!input_dev) {
+ pr_warn_once("%s: input_dev is NULL\n", __func__);
+ return;
+ }
+
+ wacom = input_get_drvdata(input_dev);
+
for (i = 0; i < wacom->led.count; i++)
wacom_update_led(wacom, button_count, mask, i);
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v5 2/6] HID: wacom: check the input devices in the legacy irq handlers
2026-11-23 4:20 [PATCH v5 0/6] HID: wacom: guard against NULL input devices on successful probe Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 1/6] HID: wacom: check the input device in the shared report helpers Jinmo Yang
@ 2026-11-23 4:20 ` Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 3/6] HID: wacom: add NULL input guards to wacom_intuos_irq() and its helpers Jinmo Yang
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Jinmo Yang @ 2026-11-23 4:20 UTC (permalink / raw)
To: ping.cheng, jason.gerecke, jikos, bentiss
Cc: dmitry.torokhov, linux-input, linux-kernel, Jinmo Yang, stable,
Claude Opus 4 . 6
wacom_penpartner_irq(), wacom_pl_irq(), wacom_ptu_irq(),
wacom_dtu_irq(), wacom_dtus_irq() and wacom_graphire_irq() dereference
pen_input and, for the latter two, pad_input without checking them.
As described in "HID: wacom: check the input device in the shared
report helpers", a partial interface leaves one or two of the three
input devices NULL on a fully successful probe, and wacom_wac_irq()
still dispatches to these handlers. Seven locations fault, each
reproduced on linux-next 20260925 (x86_64, KASAN) from one /dev/uhid
device plus a single UHID_INPUT2 write.
For wacom_dtus_irq() and wacom_graphire_irq(), all hardware served by
these handlers is expected to have both pen and pad on a single
interface, with two exceptions: GRAPHIRE (pen-only) and DTUSX (pen-only,
no pad buttons). Guard the expected input devices at function entry,
skipping the pad_input requirement for those two types. For DTUSX, also
guard the DTUSPAD branch in case a spoofed device sends a pad report
anyway.
wacom_dtu_irq() gets a check too. Its only dereference is in a
dev_dbg(), so it does not fault with CONFIG_DYNAMIC_DEBUG=n, but it is
unconditional in the source.
Fixes: 2a6cdbdd4cc0 ("HID: wacom: Introduce new 'touch_input' device")
Fixes: 862cf5535c0c ("HID: wacom: Introduce a new WACOM_DEVICETYPE_PAD device_type")
Cc: stable@vger.kernel.org
Signed-off-by: Jinmo Yang <jinmo44.yang@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
---
drivers/hid/wacom_wac.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index c7bf0e5988e5..d5c2efcc09b8 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -128,6 +128,12 @@ static int wacom_penpartner_irq(struct wacom_wac *wacom)
unsigned char *data = wacom->data;
struct input_dev *input = wacom->pen_input;
+ if (!input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: pen_input is NULL\n", __func__);
+ return 0;
+ }
+
switch (data[0]) {
case 1:
if (data[5] & 0x80) {
@@ -174,6 +180,12 @@ static int wacom_pl_irq(struct wacom_wac *wacom)
struct input_dev *input = wacom->pen_input;
int prox, pressure;
+ 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) {
dev_dbg(input->dev.parent,
"%s: received unknown report #%d\n", __func__, data[0]);
@@ -233,6 +245,12 @@ static int wacom_ptu_irq(struct wacom_wac *wacom)
unsigned char *data = wacom->data;
struct input_dev *input = wacom->pen_input;
+ 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) {
dev_dbg(input->dev.parent,
"%s: received unknown report #%d\n", __func__, data[0]);
@@ -263,6 +281,12 @@ static int wacom_dtu_irq(struct wacom_wac *wacom)
struct input_dev *input = wacom->pen_input;
int prox = data[1] & 0x20;
+ if (!input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: pen_input is NULL\n", __func__);
+ return 0;
+ }
+
dev_dbg(input->dev.parent,
"%s: received report #%d", __func__, data[0]);
@@ -289,16 +313,26 @@ static int wacom_dtu_irq(struct wacom_wac *wacom)
static int wacom_dtus_irq(struct wacom_wac *wacom)
{
+ struct wacom_features *features = &wacom->features;
unsigned char *data = wacom->data;
struct input_dev *input = wacom->pen_input;
unsigned short prox, pressure = 0;
+ if (!input || (!wacom->pad_input && features->type != DTUSX)) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: missing input device(s)\n",
+ __func__);
+ return 0;
+ }
+
if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
dev_dbg(input->dev.parent,
"%s: received unknown report #%d", __func__, data[0]);
return 0;
} else if (data[0] == WACOM_REPORT_DTUSPAD) {
input = wacom->pad_input;
+ if (!input)
+ return 0;
input_report_key(input, BTN_0, (data[1] & 0x01));
input_report_key(input, BTN_1, (data[1] & 0x02));
input_report_key(input, BTN_2, (data[1] & 0x04));
@@ -349,6 +383,12 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
int rw = 0;
int retval = 0;
+ if (!input || (!pad_input && features->type != GRAPHIRE)) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: missing input device(s)\n", __func__);
+ return 0;
+ }
+
if (features->type == GRAPHIRE_BT) {
if (data[0] != WACOM_REPORT_PENABLED_BT) {
dev_dbg(input->dev.parent,
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v5 3/6] HID: wacom: add NULL input guards to wacom_intuos_irq() and its helpers
2026-11-23 4:20 [PATCH v5 0/6] HID: wacom: guard against NULL input devices on successful probe Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 1/6] HID: wacom: check the input device in the shared report helpers Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 2/6] HID: wacom: check the input devices in the legacy irq handlers Jinmo Yang
@ 2026-11-23 4:20 ` Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 4/6] HID: wacom: add NULL input guards to wacom_intuos_bt_irq() Jinmo Yang
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Jinmo Yang @ 2026-11-23 4:20 UTC (permalink / raw)
To: ping.cheng, jason.gerecke, jikos, bentiss
Cc: dmitry.torokhov, linux-input, linux-kernel, Jinmo Yang, Claude Opus 5
Since commit 2f985de0afbe ("HID: wacom: fix wacom_intuos_irq NULL
pen_input deref"), wacom_intuos_irq() no longer dereferences pen_input
itself. Its helpers wacom_intuos_inout() and wacom_intuos_general()
still do, unconditionally: each takes wacom->pen_input into a local and
calls input_report_*() on it. pen_input can be NULL when
wacom_setup_pen_input_capabilities() returns -ENODEV during a successful
probe. Both helpers are called only from wacom_intuos_irq(), so guard
them there, after the pad block so that a device with a valid pad but no
pen keeps reporting pad events.
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@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---
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 d5c2efcc09b8..b162f40397be 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)
@@ -1089,7 +1095,13 @@ static int wacom_intuos_irq(struct wacom_wac *wacom_wac)
/* process pad events */
result = wacom_intuos_pad(wacom_wac);
if (result)
- return result;
+ return result - 1;
+
+ if (!wacom_wac->pen_input) {
+ dev_warn_once(&wacom->hdev->dev,
+ "%s: pen_input is NULL\n", __func__);
+ return 0;
+ }
/* process in/out prox events */
result = wacom_intuos_inout(wacom_wac);
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v5 4/6] HID: wacom: add NULL input guards to wacom_intuos_bt_irq()
2026-11-23 4:20 [PATCH v5 0/6] HID: wacom: guard against NULL input devices on successful probe Jinmo Yang
` (2 preceding siblings ...)
2026-11-23 4:20 ` [PATCH v5 3/6] HID: wacom: add NULL input guards to wacom_intuos_irq() and its helpers Jinmo Yang
@ 2026-11-23 4:20 ` Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 5/6] HID: wacom: add NULL input guards to Bamboo handlers Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 6/6] HID: wacom: add NULL touch_input guards to remaining touch handlers Jinmo Yang
5 siblings, 0 replies; 7+ messages in thread
From: Jinmo Yang @ 2026-11-23 4:20 UTC (permalink / raw)
To: ping.cheng, jason.gerecke, jikos, bentiss
Cc: dmitry.torokhov, linux-input, linux-kernel, Jinmo Yang,
Claude Opus 4 . 6
wacom_intuos_bt_irq() dereferences wacom->pen_input in every switch
branch, both directly for dev_warn/dev_dbg and indirectly through
wacom_intuos_bt_process_data() which calls input_sync(pen_input).
pad_input is also used in wacom_intuos_bt_process_data().
Both can be NULL when the corresponding setup_*_input_capabilities()
returns -ENODEV during a successful probe. For INTUOS4WL, pen and pad
are always expected together, so guard both at function entry.
Fixes: 2a6cdbdd4cc0 ("HID: wacom: Introduce new 'touch_input' device")
Signed-off-by: Jinmo Yang <jinmo44.yang@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
---
drivers/hid/wacom_wac.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index b162f40397be..e2c2bdf91c5b 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1269,6 +1269,13 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
int i = 1;
unsigned power_raw, battery_capacity, bat_charging, ps_connected;
+ if (!wacom->pen_input || !wacom->pad_input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: expected pen and pad input devices\n",
+ __func__);
+ return 0;
+ }
+
switch (data[0]) {
case 0x04:
if (len < 32) {
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v5 5/6] HID: wacom: add NULL input guards to Bamboo handlers
2026-11-23 4:20 [PATCH v5 0/6] HID: wacom: guard against NULL input devices on successful probe Jinmo Yang
` (3 preceding siblings ...)
2026-11-23 4:20 ` [PATCH v5 4/6] HID: wacom: add NULL input guards to wacom_intuos_bt_irq() Jinmo Yang
@ 2026-11-23 4:20 ` Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 6/6] HID: wacom: add NULL touch_input guards to remaining touch handlers Jinmo Yang
5 siblings, 0 replies; 7+ messages in thread
From: Jinmo Yang @ 2026-11-23 4:20 UTC (permalink / raw)
To: ping.cheng, jason.gerecke, jikos, bentiss
Cc: dmitry.torokhov, linux-input, linux-kernel, Jinmo Yang,
Claude Opus 4 . 6
wacom_bpt_touch() dereferences both touch_input and pad_input.
wacom_bpt3_touch_msg() dereferences touch_input.
wacom_bpt3_button_msg() dereferences pad_input.
wacom_bpt_pen() dereferences pen_input.
All four can be NULL when the corresponding
wacom_setup_{pen,touch,pad}_input_capabilities() returns -ENODEV during
a successful probe. Add per-function guards.
Fixes: 2a6cdbdd4cc0 ("HID: wacom: Introduce new 'touch_input' device")
Fixes: 862cf5535c0c ("HID: wacom: Introduce a new WACOM_DEVICETYPE_PAD device_type")
Signed-off-by: Jinmo Yang <jinmo44.yang@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
---
drivers/hid/wacom_wac.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index e2c2bdf91c5b..db8d3432dbd7 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -3177,6 +3177,12 @@ static int wacom_bpt_touch(struct wacom_wac *wacom)
if (data[0] != 0x02)
return 0;
+ if (!input || !pad_input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: input is NULL\n", __func__);
+ return 0;
+ }
+
for (i = 0; i < 2; i++) {
int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
bool touch = report_touch_events(wacom)
@@ -3211,8 +3217,17 @@ static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
{
struct wacom_features *features = &wacom->features;
struct input_dev *input = wacom->touch_input;
- bool touch = data[1] & 0x80;
- int slot = input_mt_get_slot_by_key(input, data[0]);
+ bool touch;
+ int slot;
+
+ if (!input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: touch_input is NULL\n", __func__);
+ return;
+ }
+
+ touch = data[1] & 0x80;
+ slot = input_mt_get_slot_by_key(input, data[0]);
if (slot < 0)
return;
@@ -3255,6 +3270,12 @@ static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
struct input_dev *input = wacom->pad_input;
struct wacom_features *features = &wacom->features;
+ if (!input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: pad_input is NULL\n", __func__);
+ return;
+ }
+
if (features->type == INTUOSHT || features->type == INTUOSHT2) {
input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
@@ -3309,6 +3330,12 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
if (data[0] != WACOM_REPORT_PENABLED)
return 0;
+ if (!input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: pen_input is NULL\n", __func__);
+ return 0;
+ }
+
range = (data[1] & 0x80) == 0x80;
prox = (data[1] & 0x40) == 0x40;
rdy = (data[1] & 0x20) == 0x20;
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v5 6/6] HID: wacom: add NULL touch_input guards to remaining touch handlers
2026-11-23 4:20 [PATCH v5 0/6] HID: wacom: guard against NULL input devices on successful probe Jinmo Yang
` (4 preceding siblings ...)
2026-11-23 4:20 ` [PATCH v5 5/6] HID: wacom: add NULL input guards to Bamboo handlers Jinmo Yang
@ 2026-11-23 4:20 ` Jinmo Yang
5 siblings, 0 replies; 7+ messages in thread
From: Jinmo Yang @ 2026-11-23 4:20 UTC (permalink / raw)
To: ping.cheng, jason.gerecke, jikos, bentiss
Cc: dmitry.torokhov, linux-input, linux-kernel, Jinmo Yang, stable,
Claude Opus 4 . 6
wacom_24hdt_irq() (also handles WACOM_27QHDT), wacom_intuos_pro2_bt_touch(),
and wacom_bamboo_pad_touch_event() dereference wacom->touch_input without
checking it.
As with the other handlers in this series, touch_input can be NULL when
wacom_setup_touch_input_capabilities() returns -ENODEV during an
otherwise successful probe.
Fixes: 2a6cdbdd4cc0 ("HID: wacom: Introduce new 'touch_input' device")
Cc: stable@vger.kernel.org
Signed-off-by: Jinmo Yang <jinmo44.yang@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
---
drivers/hid/wacom_wac.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index db8d3432dbd7..c48f957f8970 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1489,6 +1489,12 @@ static void wacom_intuos_pro2_bt_touch(struct wacom_wac *wacom)
int num_contacts_left = 5;
int i, j;
+ if (!touch_input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: touch_input is NULL\n", __func__);
+ return;
+ }
+
for (i = 0; i < finger_frames; i++) {
unsigned char *frame = &data[i*finger_frame_len + 109];
int current_num_contacts = frame[0] & 0x7F;
@@ -1660,6 +1666,12 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
int y_offset = 2;
+ if (!input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: touch_input is NULL\n", __func__);
+ return 0;
+ }
+
if (touch_is_muted(wacom) && !wacom->shared->touch_down)
return 0;
@@ -3450,6 +3462,12 @@ static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
int x, y;
bool valid;
+ if (!input) {
+ dev_warn_once(&container_of(wacom, struct wacom, wacom_wac)->hdev->dev,
+ "%s: touch_input is NULL\n", __func__);
+ return 0;
+ }
+
prefix = data[0];
for (id = 0; id < wacom->features.touch_max; id++) {
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-23 4:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 4:20 [PATCH v5 0/6] HID: wacom: guard against NULL input devices on successful probe Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 1/6] HID: wacom: check the input device in the shared report helpers Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 2/6] HID: wacom: check the input devices in the legacy irq handlers Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 3/6] HID: wacom: add NULL input guards to wacom_intuos_irq() and its helpers Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 4/6] HID: wacom: add NULL input guards to wacom_intuos_bt_irq() Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 5/6] HID: wacom: add NULL input guards to Bamboo handlers Jinmo Yang
2026-11-23 4:20 ` [PATCH v5 6/6] HID: wacom: add NULL touch_input guards to remaining touch handlers Jinmo Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®