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 v7 1/2] HID: haptic: reorder try_module_get/get_device before input_ff_create
Date: Fri, 16 Oct 2026 16:42:58 +0000 [thread overview]
Message-ID: <sashiko-outbox-174656@kernel.org> (raw)
In-Reply-To: <20261016163349.3293666-2-qwe.aldo@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] input: FF_HAPTIC capability lost due to input_set_capability() reordering
--
commit 212e1315f3df5903b889706323b41c9477dd030e
Author: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
HID: haptic: reorder try_module_get/get_device before input_ff_create
Move try_module_get() and get_device() before input_ff_create() in
hid_haptic_init(). The original order placed them after input_ff_create(),
and failures went to input_free which called input_ff_destroy() without
ever setting ret.
> diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
> index 8760eeb08b2cd..9753bbff9d0d0 100644
> --- a/drivers/hid/hid-haptic.c
> +++ b/drivers/hid/hid-haptic.c
[ ... ]
> @@ -499,39 +497,36 @@ int hid_haptic_init(struct hid_device *hdev,
> fill_effect_buf(haptic, &stop_effect, &haptic->stop_effect,
> HID_HAPTIC_ORDINAL_WAVEFORMSTOP);
>
> - input_set_capability(dev, EV_FF, FF_HAPTIC);
> + if (!try_module_get(THIS_MODULE)) {
> + dev_err(&hdev->dev, "Failed to increase module count.\n");
> + ret = -ENODEV;
> + goto stop_buffer_free;
> + }
> + 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;
> + }
>
> - flush = dev->flush;
> - event = dev->event;
> ret = input_ff_create(dev, FF_MAX_EFFECTS);
> if (ret) {
> dev_err(&hdev->dev, "Failed to create ff device.\n");
> + put_device(&hdev->dev);
> + module_put(THIS_MODULE);
> goto stop_buffer_free;
> }
>
> + input_set_capability(dev, EV_FF, FF_HAPTIC);
[Severity: High]
Does moving this call after input_ff_create() break the haptic functionality?
Looking at input_ff_create() in drivers/input/ff-core.c, it iterates over
dev->ffbit and copies the supported effects into the newly created ff device:
/* Copy "true" bits into ff device bitmap */
for_each_set_bit(i, dev->ffbit, FF_CNT)
__set_bit(i, ff->ffbit);
If input_set_capability() is called after input_ff_create(), FF_HAPTIC won't be
present in dev->ffbit during the copy. This leaves the internal state incomplete
because ff->ffbit will lack the capability, causing the input core to reject
haptic effects when userspace attempts to upload them.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261016163349.3293666-1-qwe.aldo@gmail.com?part=1
next prev parent reply other threads:[~2026-10-16 16:42 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
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 [this message]
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-174656@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.