From: sashiko-bot@kernel.org
To: "Aldo Ariel Panzardo" <qwe.aldo@gmail.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v5 1/2] HID: haptic: reorder try_module_get/get_device before input_ff_create
Date: Fri, 16 Oct 2026 14:06:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-174419@kernel.org> (raw)
In-Reply-To: <20261016135516.2957381-2-qwe.aldo@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] input: missing EV_FF capability cleanup on failure leads to NULL deref
--
commit 58557bc733a3a68f242cf09872b1a593ec599fc2
Author: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
HID: haptic: reorder try_module_get/get_device before input_ff_create
This commit moves try_module_get() and get_device() before input_ff_create()
in hid_haptic_init() to acquire references early. It adjusts the error
handling to jump to stop_buffer_free directly on failure, removing the need
to restore handlers or call input_ff_destroy().
> diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
> index 8760eeb08b2cd..592b44e020d6b 100644
> --- a/drivers/hid/hid-haptic.c
> +++ b/drivers/hid/hid-haptic.c
[ ... ]
> @@ -499,11 +499,23 @@ int hid_haptic_init(struct hid_device *hdev,
>
> input_set_capability(dev, EV_FF, FF_HAPTIC);
>
> - flush = dev->flush;
> - event = dev->event;
> + if (!try_module_get(THIS_MODULE)) {
> + dev_err(&hdev->dev, "Failed to increase module count.\n");
> + ret = -ENODEV;
> + goto stop_buffer_free;
> + }
[Severity: High]
Does this error path leave the EV_FF capability set on the input device?
Before this change, the failure paths for try_module_get() and get_device()
jumped to input_free, which called input_ff_destroy(dev).
By jumping to stop_buffer_free instead, the EV_FF capability remains set on
the device, but dev->ff is never initialized.
If hid_haptic_init() returns an error that is ignored by its caller, the
partially initialized input device could be registered.
When a userspace application opens the input event node and issues a force
feedback ioctl, could the input core's input_ff_upload() dereference a null
pointer?
For example, in drivers/input/ff-core.c:input_ff_upload():
if (!test_bit(effect->type, ff->ffbit)) {
Because test_bit(EV_FF, dev->evbit) is true, the input core might assume
dev->ff is valid (where ff aliases dev->ff) and cause a kernel panic.
> + if (!get_device(&hdev->dev)) {
> + dev_err(&hdev->dev, "Failed to get hdev device.\n");
> + ret = -ENODEV;
> + module_put(THIS_MODULE);
> + goto stop_buffer_free;
> + }
> +
> ret = input_ff_create(dev, FF_MAX_EFFECTS);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261016135516.2957381-1-qwe.aldo@gmail.com?part=1
next prev parent reply other threads:[~2026-10-16 14:06 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261009103333.2476105-1-qwe.aldo@gmail.com>
2026-10-16 13:55 ` [PATCH v5 0/2] HID: multitouch: fix use-after-free of haptic data on delayed input release Aldo Ariel Panzardo
2026-10-16 13:55 ` [PATCH v5 1/2] HID: haptic: reorder try_module_get/get_device before input_ff_create Aldo Ariel Panzardo
2026-10-16 14:06 ` sashiko-bot [this message]
2026-10-16 13:55 ` [PATCH v5 2/2] HID: multitouch: fix use-after-free of haptic data on delayed input release Aldo Ariel Panzardo
2026-10-16 14:12 ` sashiko-bot
2026-10-16 15:13 ` [PATCH v6 0/2] " Aldo Ariel Panzardo
2026-10-16 15:13 ` [PATCH v6 1/2] HID: haptic: reorder try_module_get/get_device before input_ff_create Aldo Ariel Panzardo
2026-10-16 15:35 ` sashiko-bot
2026-10-16 15:13 ` [PATCH v6 2/2] HID: multitouch: fix use-after-free of haptic data on delayed input release Aldo Ariel Panzardo
2026-10-16 16:33 ` [PATCH v7 0/2] " Aldo Ariel Panzardo
2026-10-16 16:33 ` [PATCH v7 1/2] HID: haptic: reorder try_module_get/get_device before input_ff_create Aldo Ariel Panzardo
2026-10-16 16:42 ` sashiko-bot
2026-10-16 18:16 ` Dmitry Torokhov
2026-10-16 16:33 ` [PATCH v7 2/2] HID: multitouch: fix use-after-free of haptic data on delayed input release Aldo Ariel Panzardo
2026-10-16 17:30 ` [PATCH v8 0/2] " Aldo Ariel Panzardo
2026-10-16 17:30 ` [PATCH v8 1/2] HID: haptic: reorder try_module_get/get_device before input_ff_create Aldo Ariel Panzardo
2026-10-16 17:30 ` [PATCH v8 2/2] HID: multitouch: fix use-after-free of haptic data on delayed input release Aldo Ariel Panzardo
2026-10-16 18:27 ` Dmitry Torokhov
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=sashiko-outbox-174419@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=qwe.aldo@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.