Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sanjay Chitroda" <sanjayembeddedse@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH 09/10] iio: position: hid-sensor-custom-intel-hinge: use local struct device
Date: Mon, 20 Jul 2026 09:59:45 +0000	[thread overview]
Message-ID: <20260720095946.276E31F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260720-hid-iio-local-struct-device-v1-9-74496fee6327@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Possible Use-After-Free of `hinge_state` and its embedded `callbacks` during driver unbind or probe error paths, due to lack of synchronization with concurrent HID sensor events.
--

--- Patch [9]: [PATCH 09/10] iio: position: hid-sensor-custom-intel-hinge: use local struct device ---
commit 7aa4981763773e6c94e52f6b3bcf4d8c0d85b050
Author: Sanjay Chitroda <sanjayembeddedse@gmail.com>

iio: position: hid-sensor-custom-intel-hinge: use local struct device

Introduce a local struct device pointer derived from pdev->dev to avoid
repeated pdev->dev usage and improve readability.

> diff --git a/drivers/iio/position/hid-sensor-custom-intel-hinge.c b/drivers/iio/position/hid-sensor-custom-intel-hinge.c
> index d275bc1413feb..febc32f5a3328 100644
> --- a/drivers/iio/position/hid-sensor-custom-intel-hinge.c
> +++ b/drivers/iio/position/hid-sensor-custom-intel-hinge.c

[ ... ]

> @@ -322,13 +323,13 @@ static int hid_hinge_probe(struct platform_device *pdev)
>  	st->callbacks.pdev = pdev;
>  	ret = sensor_hub_register_callback(hsdev, hsdev->usage, &st->callbacks);
>  	if (ret < 0) {
> -		dev_err(&pdev->dev, "callback reg failed\n");
> +		dev_err(dev, "callback reg failed\n");
>  		goto error_remove_trigger;
>  	}
>  
>  	ret = iio_device_register(indio_dev);
>  	if (ret) {
> -		dev_err(&pdev->dev, "device register failed\n");
> +		dev_err(dev, "device register failed\n");
>  		goto error_remove_callback;
>  	}
>  
> 	return ret;
> 
> error_remove_callback:
> 	sensor_hub_remove_callback(hsdev, hsdev->usage);

[Severity: High]
This is a pre-existing issue, but can this lead to a use-after-free during
the probe error path or device unbind?

If iio_device_register() fails, sensor_hub_remove_callback() removes the
callback from the list but does not appear to synchronize with
sensor_hub_raw_event() which might be concurrently executing the callback.

Since the hinge_state structure is allocated with devm_iio_device_alloc(),
returning from hid_hinge_probe() will cause the devres framework to
prematurely free the memory while the concurrent event handler is actively
writing to it.

Does there need to be some synchronization to ensure pending events are
flushed before the devres cleanup occurs?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260720-hid-iio-local-struct-device-v1-0-74496fee6327@gmail.com?part=9

  reply	other threads:[~2026-07-20  9:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20  9:40 [PATCH 00/10] HID: iio: use local struct device Sanjay Chitroda via B4 Relay
2026-07-20  9:40 ` [PATCH 01/10] iio: humidity: hid-sensor-humidity: " Sanjay Chitroda via B4 Relay
2026-07-20  9:49   ` sashiko-bot
2026-07-20  9:40 ` [PATCH 02/10] iio: gyro: hid-sensor-gyro-3d: " Sanjay Chitroda via B4 Relay
2026-07-20 11:54   ` Andy Shevchenko
2026-07-20 16:50     ` Sanjay Chitroda
2026-07-20 19:35       ` Andy Shevchenko
2026-07-20  9:40 ` [PATCH 03/10] iio: accel: hid-sensor-accel-3d: " Sanjay Chitroda via B4 Relay
2026-07-20  9:40 ` [PATCH 04/10] iio: light: hid-sensor-als: " Sanjay Chitroda via B4 Relay
2026-07-20  9:40 ` [PATCH 05/10] iio: light: hid-sensor-prox: " Sanjay Chitroda via B4 Relay
2026-07-20  9:40 ` [PATCH 06/10] iio: magnetometer: hid-sensor-magn-3d: " Sanjay Chitroda via B4 Relay
2026-07-20  9:40 ` [PATCH 07/10] iio: orientation: hid-sensor-incl-3d: " Sanjay Chitroda via B4 Relay
2026-07-20  9:40 ` [PATCH 08/10] iio: orientation: hid-sensor-rotation: " Sanjay Chitroda via B4 Relay
2026-07-20  9:40 ` [PATCH 09/10] iio: position: hid-sensor-custom-intel-hinge: " Sanjay Chitroda via B4 Relay
2026-07-20  9:59   ` sashiko-bot [this message]
2026-07-20  9:40 ` [PATCH 10/10] iio: pressure: hid-sensor-press: " Sanjay Chitroda via B4 Relay

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=20260720095946.276E31F00A3A@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