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,
syzbot+093e05755c2d99caab91@syzkaller.appspotmail.com,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
sashiko-bot@kernel.org,
Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
Subject: [PATCH v2] HID: multitouch: use GFP_ATOMIC for report/application allocations
Date: Thu, 10 Sep 2026 23:23:31 +0700 [thread overview]
Message-ID: <20260910162331.31578-1-ngocthang2710.1999@gmail.com> (raw)
In-Reply-To: <20260910155305.58E4A1F000FF@smtp.kernel.org>
mt_allocate_report_data() and mt_allocate_application() devm_kzalloc()
with GFP_KERNEL, but they are reachable from mt_event()/mt_report()
via hid_report_raw_event(), which can run in (soft)irq context off a
USB URB completion (e.g. dummy_hcd's hrtimer softirq). GFP_KERNEL
there may call into fs_reclaim, which lockdep flags as an
inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} use of fs_reclaim,
alongside a "sleeping function called from invalid context" splat.
Switch both to GFP_ATOMIC since neither is on a path that needs to
sleep. mt_allocate_usage() is left at GFP_KERNEL: it is only reached
from mt_touch_input_mapping(), which runs at probe time (hid_hw_start()),
never from mt_event(), so it does not need the downgrade.
Reported-by: syzbot+093e05755c2d99caab91@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=093e05755c2d99caab91
Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
---
v2:
- Keep mt_allocate_usage() at GFP_KERNEL. It is only reached from
mt_touch_input_mapping(), at probe time, never from mt_event(), so
the GFP_ATOMIC downgrade there was unnecessary.
(feedback from sashiko-bot)
---
drivers/hid/hid-multitouch.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 2c41bacab1ca..9b78f8f23fcf 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -604,6 +604,7 @@ static struct mt_usages *mt_allocate_usage(struct hid_device *hdev,
{
struct mt_usages *usage;
+ /* only called from mt_touch_input_mapping(), at probe time */
usage = devm_kzalloc(&hdev->dev, sizeof(*usage), GFP_KERNEL);
if (!usage)
return NULL;
@@ -633,8 +634,9 @@ static struct mt_application *mt_allocate_application(struct mt_device *td,
unsigned int application = report->application;
struct mt_application *mt_application;
+ /* may run from hid_report_raw_event() in (soft)irq context */
mt_application = devm_kzalloc(&td->hdev->dev, sizeof(*mt_application),
- GFP_KERNEL);
+ GFP_ATOMIC);
if (!mt_application)
return NULL;
@@ -692,7 +694,8 @@ static struct mt_report_data *mt_allocate_report_data(struct mt_device *td,
struct hid_field *field;
int r, n;
- rdata = devm_kzalloc(&td->hdev->dev, sizeof(*rdata), GFP_KERNEL);
+ /* may run from hid_report_raw_event() in (soft)irq context */
+ rdata = devm_kzalloc(&td->hdev->dev, sizeof(*rdata), GFP_ATOMIC);
if (!rdata)
return NULL;
--
2.43.0
next prev parent reply other threads:[~2026-09-10 16:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 15:37 [PATCH] HID: multitouch: use GFP_ATOMIC for report/application/usage allocations Nguyen Ngoc Thang
2026-09-10 15:53 ` sashiko-bot
2026-09-10 16:23 ` Nguyen Ngoc Thang [this message]
2026-09-10 16:42 ` [PATCH v2] HID: multitouch: use GFP_ATOMIC for report/application allocations sashiko-bot
2026-09-10 16:54 ` [PATCH v3] HID: multitouch: use GFP_ATOMIC for report/application/usage allocations Nguyen Ngoc Thang
2026-09-10 16:55 ` [PATCH v2] " Nguyen Ngoc Thang
2026-09-10 16:27 ` Nguyen Ngoc Thang
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=20260910162331.31578-1-ngocthang2710.1999@gmail.com \
--to=ngocthang2710.1999@gmail.com \
--cc=bentiss@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=syzbot+093e05755c2d99caab91@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