From: sashiko-bot@kernel.org
To: "Ayaan Mirza Baig" <ayaanmirzabaig85@gmail.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v2] HID: hid-sensor-hub: avoid lock inversion in sensor_hub_remove()
Date: Fri, 20 Nov 2026 12:21:47 +0000 [thread overview]
Message-ID: <sashiko-outbox-225135@kernel.org> (raw)
In-Reply-To: <20261120121256.35339-1-ayaanmirzabaig85@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] HID: hid-sensor-hub: NULL dereference in
sensor_hub_finalize_pending_fn()
--
commit 5391cb83740840042fa3d18d4f3751bd37f573af
Author: Ayaan Mirza Baig <ayaanmirzabaig85@gmail.com>
HID: hid-sensor-hub: avoid lock inversion in sensor_hub_remove()
This commit moves spin_lock_irqsave(&data->lock, flags) from
sensor_hub_remove() into sensor_hub_finalize_pending_fn() to avoid holding
data->lock across device_for_each_child().
> diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
> index 028e70ec7bace..4ade5b5ece565 100644
> --- a/drivers/hid/hid-sensor-hub.c
> +++ b/drivers/hid/hid-sensor-hub.c
> @@ -836,9 +836,13 @@ static int sensor_hub_probe(struct hid_device *hdev,
> static int sensor_hub_finalize_pending_fn(struct device *dev, void *data)
> {
> struct hid_sensor_hub_device *hsdev = dev->platform_data;
> + struct sensor_hub_data *sd = data;
> + unsigned long flags;
>
> + spin_lock_irqsave(&sd->lock, flags);
> if (hsdev->pending.status)
> complete(&hsdev->pending.ready);
> + spin_unlock_irqrestore(&sd->lock, flags);
>
> return 0;
> }
> @@ -846,16 +850,13 @@ static int sensor_hub_finalize_pending_fn(struct device *dev, void *data)
> static void sensor_hub_remove(struct hid_device *hdev)
> {
> struct sensor_hub_data *data = hid_get_drvdata(hdev);
> - unsigned long flags;
>
> hid_dbg(hdev, " hardware removed\n");
> hid_hw_close(hdev);
> hid_hw_stop(hdev);
>
> - spin_lock_irqsave(&data->lock, flags);
> device_for_each_child(&hdev->dev, NULL,
> sensor_hub_finalize_pending_fn);
> - spin_unlock_irqrestore(&data->lock, flags);
[Severity: High]
As reported by Arnav Kapoor on v1 [1], doesn't device_for_each_child() still
pass NULL instead of data to sensor_hub_finalize_pending_fn(), causing a NULL
pointer dereference at spin_lock_irqsave(&sd->lock, flags) whenever a sensor
hub with child devices is removed?
[1] https://lore.kernel.org/r/20261119201555.185270-1-kapoorarnav43@gmail.com
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120121256.35339-1-ayaanmirzabaig85@gmail.com?part=1
prev parent reply other threads:[~2026-11-20 12:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 12:12 [PATCH v2] HID: hid-sensor-hub: avoid lock inversion in sensor_hub_remove() Ayaan Mirza Baig
2026-11-20 12:21 ` sashiko-bot [this message]
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-225135@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ayaanmirzabaig85@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox