From: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
To: Christopher Hoover <ch@murgatroid.com>,
Jonathan Cameron <jic23@kernel.org>,
Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>
Cc: "Lixu Zhang" <lixu.zhang@intel.com>,
"Joshua Crofts" <joshua.crofts1@gmail.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v3 2/3] iio: temperature: hid-sensor-temperature: Use per-instance callbacks
Date: Mon, 02 Nov 2026 09:20:50 -0800 [thread overview]
Message-ID: <5481cb8e125b76562ee6831cf3e87a09219def02.camel@linux.intel.com> (raw)
In-Reply-To: <20261019023420.83976-3-ch@murgatroid.com>
On Sun, 2026-10-18 at 19:34 -0700, Christopher Hoover wrote:
> hid-sensor-temperature keeps a single static struct
> hid_sensor_hub_callbacks for all instances and overwrites its pdev in
> every probe. With two temperature sensors, input reports for one are
> delivered with the other's platform device; once that device is
> removed, platform_get_drvdata() returns NULL and
> temperature_capture_sample() dereferences it:
>
> BUG: kernel NULL pointer dereference, address: 00000000000003a8
> RIP: 0010:temperature_capture_sample+0xd/0x50
> [hid_sensor_temperature]
>
> The oops happens in sensor_hub_raw_event() with the hub's spinlock
> held, so the hub's removal then hangs. It reproduces with two uhid
> devices that each declare a temperature sensor, one destroyed while
> the other still sends input reports.
>
> Keep the callbacks in struct temperature_state, as the other HID
> sensor drivers (accel, gyro, als, ...) do.
>
> Fixes: 59d0f2da3569 ("iio: hid: Add temperature sensor support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Christopher Hoover <ch@murgatroid.com>
> Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> drivers/iio/temperature/hid-sensor-temperature.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/iio/temperature/hid-sensor-temperature.c
> b/drivers/iio/temperature/hid-sensor-temperature.c
> index 5e3262e461f4..4bc9d42a0301 100644
> --- a/drivers/iio/temperature/hid-sensor-temperature.c
> +++ b/drivers/iio/temperature/hid-sensor-temperature.c
> @@ -14,6 +14,7 @@
>
> struct temperature_state {
> struct hid_sensor_common common_attributes;
> + struct hid_sensor_hub_callbacks callbacks;
> struct hid_sensor_hub_attribute_info temperature_attr;
> struct {
> s32 temperature_data;
> @@ -181,11 +182,6 @@ static int temperature_parse_report(struct
> platform_device *pdev,
> return ret;
> }
>
> -static struct hid_sensor_hub_callbacks temperature_callbacks = {
> - .send_event = &temperature_proc_event,
> - .capture_sample = &temperature_capture_sample,
> -};
> -
> /* Function to initialize the processing for usage id */
> static int hid_temperature_probe(struct platform_device *pdev)
> {
> @@ -237,9 +233,13 @@ static int hid_temperature_probe(struct
> platform_device *pdev)
>
> platform_set_drvdata(pdev, indio_dev);
>
> - temperature_callbacks.pdev = pdev;
> + temp_st->callbacks = (struct hid_sensor_hub_callbacks) {
> + .send_event = temperature_proc_event,
> + .capture_sample = temperature_capture_sample,
> + .pdev = pdev,
> + };
> ret = sensor_hub_register_callback(hsdev,
> HID_USAGE_SENSOR_TEMPERATURE,
> - &temperature_callbacks);
> + &temp_st->callbacks);
> if (ret)
> goto error_remove_trigger;
>
next prev parent reply other threads:[~2026-11-02 17:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 2:34 [PATCH v3 0/3] iio: hid-sensors: fix shared callbacks in temperature and humidity Christopher Hoover
2026-10-19 2:34 ` [PATCH v3 1/3] HID: hid-sensor-hub: Synchronize callback removal with raw events Christopher Hoover
2026-10-22 1:21 ` Srinivas Pandruvada
2026-10-22 1:58 ` Christopher Hoover
2026-10-26 15:17 ` Pandruvada, Srinivas
2026-10-22 14:13 ` Andy Shevchenko
2026-11-02 17:19 ` srinivas pandruvada
2026-10-19 2:34 ` [PATCH v3 2/3] iio: temperature: hid-sensor-temperature: Use per-instance callbacks Christopher Hoover
2026-10-19 10:57 ` Andy Shevchenko
2026-11-02 17:20 ` srinivas pandruvada [this message]
2026-10-19 2:34 ` [PATCH v3 3/3] iio: humidity: hid-sensor-humidity: " Christopher Hoover
2026-10-19 10:58 ` Andy Shevchenko
2026-11-02 17:21 ` srinivas pandruvada
2026-11-02 0:33 ` [PATCH v3 0/3] iio: hid-sensors: fix shared callbacks in temperature and humidity Jonathan Cameron
2026-11-02 21:56 ` Jonathan Cameron
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=5481cb8e125b76562ee6831cf3e87a09219def02.camel@linux.intel.com \
--to=srinivas.pandruvada@linux.intel.com \
--cc=andy@kernel.org \
--cc=bentiss@kernel.org \
--cc=ch@murgatroid.com \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=jikos@kernel.org \
--cc=joshua.crofts1@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lixu.zhang@intel.com \
--cc=nuno.sa@analog.com \
--cc=stable@vger.kernel.org \
/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®