[PATCH v2] HID: multitouch: use GFP_ATOMIC for report/application allocations

From: Nguyen Ngoc Thang

Date: Thu Sep 10 2026 - 12:49:14 EST


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@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=093e05755c2d99caab91
Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@xxxxxxxxx>
---
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