From: Jinmo Yang <jinmo44.yang@gmail.com>
To: ping.cheng@wacom.com, jason.gerecke@wacom.com, jikos@kernel.org,
bentiss@kernel.org
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org, Jinmo Yang <jinmo44.yang@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH v5 1/6] HID: wacom: check the input device in the shared report helpers
Date: Mon, 23 Nov 2026 04:20:10 +0000 [thread overview]
Message-ID: <dcd2a9920a0f7a7da8b85e1b133d61e2585472c4.1795405057.git.jinmo44.yang@gmail.com> (raw)
In-Reply-To: <cover.1795405057.git.jinmo44.yang@gmail.com>
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
next prev parent reply other threads:[~2026-11-23 4:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dcd2a9920a0f7a7da8b85e1b133d61e2585472c4.1795405057.git.jinmo44.yang@gmail.com \
--to=jinmo44.yang@gmail.com \
--cc=bentiss@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=jason.gerecke@wacom.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ping.cheng@wacom.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®