Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sanjay Chitroda" <sanjayembeddedse@gmail.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v2 6/6] iio: temperature: hid-sensor-temperature: use common device for devres
Date: Thu, 02 Jul 2026 17:28:54 +0000	[thread overview]
Message-ID: <20260702172855.5E50F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260702-15-jun-hid-iio-alignment-v2-6-b87f01f5efbc@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Changing the devm_kmemdup() parent from `&indio_dev->dev` to `&pdev->dev` introduces a Use-After-Free vulnerability by violating the IIO device lifetime model.
--

commit f64b0b02100e325f644f897f84be1fbd188c0d40
Author: Sanjay Chitroda <sanjayembeddedse@gmail.com>

iio: temperature: hid-sensor-temperature: use common device for devres

This commit changes the device used for devm_kmemdup() from the IIO device
to the platform device. This aims to consolidate devres ownership under a
single parent device.

> diff --git a/drivers/iio/temperature/hid-sensor-temperature.c b/drivers/iio/temperature/hid-sensor-temperature.c
> index 18da85e6c60ed..6dfb606a53af3 100644
> --- a/drivers/iio/temperature/hid-sensor-temperature.c
> +++ b/drivers/iio/temperature/hid-sensor-temperature.c
> @@ -213,8 +213,8 @@ static int hid_temperature_probe(struct platform_device *pdev)
>  	if (ret)
>  		return ret;
>  
> -	temp_chans = devm_kmemdup(&indio_dev->dev, temperature_channels,
> -				sizeof(temperature_channels), GFP_KERNEL);
> +	temp_chans = devm_kmemdup(&pdev->dev, temperature_channels,
> +				  sizeof(temperature_channels), GFP_KERNEL);

[Severity: High]
Could tying the channel array allocated here in hid_temperature_probe() to
the platform device's devres introduce a use-after-free regression if an
in-kernel consumer holds a reference to the IIO device?

If an in-kernel IIO consumer, such as iio_hwmon, acquires a reference to a
channel of this device via iio_channel_get(), the reference count of the
logical IIO device (indio_dev) is incremented.

When the platform device (pdev) is unbound, the devres cleanup for pdev will
run and free the temp_chans array because its parent is now pdev->dev. The
devres cleanup then calls iio_device_unregister(), which drops the driver's
reference to indio_dev, but indio_dev itself remains alive due to the
consumer's reference.

If the consumer subsequently calls an IIO API like iio_read_channel_label()
or iio_get_channel_ext_info_count(), can these APIs directly dereference the
channel pointers into the freed temp_chans array without checking if the
device is unregistered?

Should the temp_chans array remain tied to &indio_dev->dev to ensure its
lifetime safely extends until the IIO device itself is fully released?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260702-15-jun-hid-iio-alignment-v2-0-b87f01f5efbc@gmail.com?part=6

  reply	other threads:[~2026-07-02 17:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02 16:17 [PATCH v2 0/6] HID: iio: warning clean up and prefer kernel coding style Sanjay Chitroda via B4 Relay
2026-07-02 16:17 ` [PATCH v2 1/6] iio: hid-sensors: add/remove blank line Sanjay Chitroda via B4 Relay
2026-07-02 17:30   ` Jonathan Cameron
2026-07-02 16:17 ` [PATCH v2 2/6] iio: hid-sensors: align function parenthesis for readability Sanjay Chitroda via B4 Relay
2026-07-02 17:20   ` Jonathan Cameron
2026-07-03 12:52     ` Andy Shevchenko
2026-07-04  1:09       ` srinivas pandruvada
2026-07-02 16:18 ` [PATCH v2 3/6] iio: hid-sensors: Use implicit NULL pointer checks Sanjay Chitroda via B4 Relay
2026-07-02 17:22   ` Jonathan Cameron
2026-07-02 16:18 ` [PATCH v2 4/6] iio: humidity: hid-sensor-humidity: use common device for devres Sanjay Chitroda via B4 Relay
2026-07-02 17:03   ` sashiko-bot
2026-07-02 17:26   ` Jonathan Cameron
2026-07-02 16:18 ` [PATCH v2 5/6] iio: position: hid-sensor-custom-intel-hinge: " Sanjay Chitroda via B4 Relay
2026-07-02 17:18   ` sashiko-bot
2026-07-02 17:26   ` Jonathan Cameron
2026-07-02 16:18 ` [PATCH v2 6/6] iio: temperature: hid-sensor-temperature: " Sanjay Chitroda via B4 Relay
2026-07-02 17:28   ` sashiko-bot [this message]
2026-07-02 17:29   ` 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=20260702172855.5E50F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=sanjayembeddedse@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox