All of lore.kernel.org
 help / color / mirror / Atom feed
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] HID: hid-sensor-hub: avoid lock inversion in sensor_hub_remove()
Date: Thu, 19 Nov 2026 19:33:46 +0000	[thread overview]
Message-ID: <sashiko-outbox-223935@kernel.org> (raw)
In-Reply-To: <20261119192046.1015750-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 1ba2998091dc7a9d09c7bc99c333bc23a67a24d5
Author: Ayaan Mirza Baig <ayaanmirzabaig85@gmail.com>

HID: hid-sensor-hub: avoid lock inversion in sensor_hub_remove()

This commit moves the acquisition of &data->lock from sensor_hub_remove()
into sensor_hub_finalize_pending_fn() to avoid holding the spinlock 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]
Does sensor_hub_remove() need to pass data instead of NULL to
device_for_each_child()?  Passing NULL causes a NULL pointer dereference
on &sd->lock in sensor_hub_finalize_pending_fn() when removing a sensor
hub with any child device.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119192046.1015750-1-ayaanmirzabaig85@gmail.com?part=1

  reply	other threads:[~2026-11-19 19:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 19:20 [PATCH] HID: hid-sensor-hub: avoid lock inversion in sensor_hub_remove() Ayaan Mirza Baig
2026-11-19 19:33 ` sashiko-bot [this message]
2026-11-19 20:15 ` Arnav Kapoor

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-223935@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 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.