From: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
To: Jiri Kosina <jikos@kernel.org>, Benjamin Tissoires <bentiss@kernel.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Harald Brinkmann <hbrinkmann@braincalibration.de>,
Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>,
syzbot+eba2b3201bd25a97cddf@syzkaller.appspotmail.com,
stable@vger.kernel.org
Subject: [PATCH] HID: saitek: don't dereference a NULL hidinput in saitek_event()
Date: Thu, 15 Oct 2026 21:34:33 +0700 [thread overview]
Message-ID: <20261015143433.129525-1-ngocthang2710.1999@gmail.com> (raw)
hid_process_event() calls the driver's ->event() for every usage of a
report, including fields that hidinput did not map to any input device,
e.g. a constant input item. For those fields field->hidinput is NULL,
and saitek_event() loads field->hidinput->input unconditionally:
KASAN: null-ptr-deref in range [0x0000000000000018-0x000000000000001f]
RIP: 0010:saitek_event+0x51/0x2b0 drivers/hid/hid-saitek.c:154
hid_process_event drivers/hid/hid-core.c:1572
hid_report_raw_event drivers/hid/hid-core.c:2109
hid_input_report drivers/hid/hid-core.c:2180
hid_irq_in drivers/hid/usbhid/hid-core.c
A device that claims to be a Saitek MMO7 and uses such a descriptor
triggers it with a single input report.
Bail out early when the field has no input device, as the other HID
drivers implementing ->event() already do.
Fixes: 37c492c8f6a9 ("HID: quirk for Saitek RAT7 and MMO7 mices' mode button")
Reported-by: syzbot+eba2b3201bd25a97cddf@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=eba2b3201bd25a97cddf
Cc: stable@vger.kernel.org
Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
---
drivers/hid/hid-saitek.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-saitek.c b/drivers/hid/hid-saitek.c
index 6fe7c087c594..2a9e07a4fc77 100644
--- a/drivers/hid/hid-saitek.c
+++ b/drivers/hid/hid-saitek.c
@@ -151,7 +151,12 @@ static int saitek_event(struct hid_device *hdev, struct hid_field *field,
struct hid_usage *usage, __s32 value)
{
struct saitek_sc *ssc = hid_get_drvdata(hdev);
- struct input_dev *input = field->hidinput->input;
+ struct input_dev *input;
+
+ if (!field->hidinput)
+ return 0;
+
+ input = field->hidinput->input;
if (usage->type == EV_KEY && value &&
(((ssc->quirks & SAITEK_RELEASE_MODE_RAT7) &&
--
2.43.0
next reply other threads:[~2026-10-15 14:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 14:34 Nguyen Ngoc Thang [this message]
2026-10-15 14:45 ` [PATCH] HID: saitek: don't dereference a NULL hidinput in saitek_event() sashiko-bot
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=20261015143433.129525-1-ngocthang2710.1999@gmail.com \
--to=ngocthang2710.1999@gmail.com \
--cc=bentiss@kernel.org \
--cc=hbrinkmann@braincalibration.de \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+eba2b3201bd25a97cddf@syzkaller.appspotmail.com \
/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