From: Arnav Kapoor <kapoorarnav43@gmail.com>
To: Ayaan Mirza Baig <ayaanmirzabaig85@gmail.com>
Cc: Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Jonathan Cameron <jic23@kernel.org>, Lee Jones <lee@kernel.org>,
Heiko Stuebner <heiko@sntech.de>,
linux-input@vger.kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org,
syzbot+fb951970a334aaff00ba@syzkaller.appspotmail.com
Subject: Re: [PATCH] HID: hid-sensor-hub: avoid lock inversion in sensor_hub_remove()
Date: Fri, 20 Nov 2026 01:45:55 +0530 [thread overview]
Message-ID: <20261119201555.185270-1-kapoorarnav43@gmail.com> (raw)
In-Reply-To: <20261119192046.1015750-1-ayaanmirzabaig85@gmail.com>
On Fri, Nov 20, 2026 at 12:50:46AM +0530, Ayaan Mirza Baig wrote:
> Move spin_lock_irqsave()/spin_unlock_irqrestore() into
> sensor_hub_finalize_pending_fn() and pass data through
> device_for_each_child(), so &data->lock is only held while inspecting
> and completing each child's pending state after klist_next() releases
> &k->k_lock.
...
> 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);
...
> device_for_each_child(&hdev->dev, NULL,
> sensor_hub_finalize_pending_fn);
The commit message says data is passed through device_for_each_child(),
but the call still passes NULL, so sd is NULL in the callback and
spin_lock_irqsave(&sd->lock, flags) dereferences it. That would oops on
every removal of a hub with child devices, instead of the lockdep
warning. Sashiko flags the same thing.
I think it should be:
device_for_each_child(&hdev->dev, data,
sensor_hub_finalize_pending_fn);
With that, moving the lock into the callback looks right to me: k_lock
is a plain spinlock, so it shouldn't nest inside data->lock, which
sensor_hub_raw_event() takes from interrupt context.
Could you send a v2 with that change, and say whether the syzbot
reproducer runs clean with it?
Thanks,
Arnav
prev parent reply other threads:[~2026-11-19 20:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 19:20 Ayaan Mirza Baig
2026-11-19 20:15 ` Arnav Kapoor [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=20261119201555.185270-1-kapoorarnav43@gmail.com \
--to=kapoorarnav43@gmail.com \
--cc=ayaanmirzabaig85@gmail.com \
--cc=bentiss@kernel.org \
--cc=heiko@sntech.de \
--cc=jic23@kernel.org \
--cc=jikos@kernel.org \
--cc=lee@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=syzbot+fb951970a334aaff00ba@syzkaller.appspotmail.com \
/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
all inboxes | Powered by JetHome®