From: Esben Haabendal <esben@geanix.com>
To: <sashiko-bot@kernel.org>
Cc: <sashiko-reviews@lists.linux.dev>, <conor+dt@kernel.org>,
<devicetree@vger.kernel.org>, <robh@kernel.org>
Subject: Re: [PATCH RESEND v5 6/6] iio: accel: mma8452: Reuse existing dev pointer in mma8452_probe()
Date: Wed, 19 Aug 2026 14:24:05 +0200 [thread overview]
Message-ID: <87zeyiz4be.fsf@geanix.com> (raw)
In-Reply-To: <20260819082804.22A971F000E9@smtp.kernel.org> (sashiko-bot@kernel.org's message of "Wed, 19 Aug 2026 08:28:03 +0000")
<sashiko-bot@kernel.org> writes:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
>
> New issues:
> - [Low] Compilation Error in mma8452_runtime_suspend() due to undeclared identifier 'client'.
>
> Pre-existing issues:
> - [High] Missing pm_runtime_disable() in mma8452_probe() error paths leads to a guaranteed NULL pointer dereference in the autosuspend callback.
> --
>
> --- Patch [6]: [PATCH RESEND v5 6/6] iio: accel: mma8452: Reuse existing dev pointer in mma8452_probe() ---
> commit 004c22b83c7e1b63662958bd7b1a838d3015cf83
> Author: Esben Haabendal <esben@geanix.com>
>
> iio: accel: mma8452: Reuse existing dev pointer in mma8452_probe()
>
> In commit 32a5c04d4575 ("iio: accel: mma8452: Use dev_err_probe()") the
> struct device * pointer was assigned to local variable dev, so we can just
> as well reuse that throughout the function for sligthly more readable code.
>
>> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
>> index 060a6207e52d0..bf5cb1c4425a3 100644
>> --- a/drivers/iio/accel/mma8452.c
>> +++ b/drivers/iio/accel/mma8452.c
>
> [ ... ]
>
>> @@ -1731,14 +1730,13 @@ static int mma8452_probe(struct i2c_client *client)
>> goto buffer_cleanup;
>> }
>>
>> - ret = pm_runtime_set_active(&client->dev);
>> + ret = pm_runtime_set_active(dev);
>> if (ret < 0)
>> goto free_irq;
>>
>> - pm_runtime_enable(&client->dev);
>> - pm_runtime_set_autosuspend_delay(&client->dev,
>> - MMA8452_AUTO_SUSPEND_DELAY_MS);
>> - pm_runtime_use_autosuspend(&client->dev);
>> + pm_runtime_enable(dev);
>> + pm_runtime_set_autosuspend_delay(dev, MMA8452_AUTO_SUSPEND_DELAY_MS);
>> + pm_runtime_use_autosuspend(dev);
>>
>> ret = iio_device_register(indio_dev);
>> if (ret < 0)
>
> [Severity: High]
> This is a pre-existing issue, but if mma8452_probe() fails here, is there a
> missing pm_runtime_disable() in the error paths?
>
> If mma8452_probe() fails after enabling PM runtime (for example, during
> iio_device_register()), it returns an error without disabling PM runtime or
> autosuspend. The driver core cleans up the device and clears its driver data
> via dev_set_drvdata(dev, NULL), and queues an idle notification.
>
> Because PM runtime is still active, this triggers the autosuspend timer.
> When the timer expires, the autosuspend callback executes:
>
> drivers/iio/accel/mma8452.c:mma8452_runtime_suspend() {
> struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> struct mma8452_data *data = iio_priv(indio_dev);
> ...
> }
>
> Does this lead to a reliable NULL pointer dereference when iio_priv()
> dereferences the cleared driver data?
I would think so. I will add a fix to the series, calling both
pm_runtime_disable() and pm_runtime_set_suspended().
> [Severity: Low]
> Also, looking at mma8452_runtime_suspend(), does the module fail to compile
> when CONFIG_PM is enabled due to an undeclared identifier?
>
> The code attempts to call synchronize_irq():
>
> drivers/iio/accel/mma8452.c:mma8452_runtime_suspend() {
> ...
> synchronize_irq(client->irq);
> ...
> }
>
> Since client is not declared in the scope of mma8452_runtime_suspend(),
> should this access data->client->irq instead?
Ok. That is strange. I was very sure I tested this exact patch version,
but I must have made a mistake. I will fix, and make sure I test it
properly (obviously with CONFIG_PM enabled to actually test it).
/Esben
next prev parent reply other threads:[~2026-08-19 12:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 8:15 [PATCH RESEND v5 0/6] io: accel: mma8452: Allow open drain interrupt pin configuration Esben Haabendal
2026-08-19 8:15 ` [PATCH RESEND v5 1/6] dt-bindings: iio: accel: mma8452: Add drive-open-drain Esben Haabendal
2026-08-19 8:15 ` [PATCH RESEND v5 2/6] iio: accel: mma8452: Optimize struct mma8452_data member orders Esben Haabendal
2026-08-19 8:27 ` sashiko-bot
2026-08-19 8:15 ` [PATCH RESEND v5 3/6] iio: accel: mma8452: Only apply trigger type when not set by firmware Esben Haabendal
2026-08-19 8:29 ` sashiko-bot
2026-08-19 8:15 ` [PATCH RESEND v5 4/6] iio: accel: mma8452: Support interrupt sharing Esben Haabendal
2026-08-19 8:25 ` sashiko-bot
2026-08-19 8:44 ` Esben Haabendal
2026-08-19 13:54 ` Andy Shevchenko
2026-08-19 8:15 ` [PATCH RESEND v5 5/6] iio: accel: mma8452: Allow open drain interrupt pin configuration Esben Haabendal
2026-08-19 8:29 ` sashiko-bot
2026-08-19 8:15 ` [PATCH RESEND v5 6/6] iio: accel: mma8452: Reuse existing dev pointer in mma8452_probe() Esben Haabendal
2026-08-19 8:25 ` Joshua Crofts
2026-08-19 8:28 ` sashiko-bot
2026-08-19 12:24 ` Esben Haabendal [this message]
2026-08-19 13:56 ` Andy Shevchenko
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=87zeyiz4be.fsf@geanix.com \
--to=esben@geanix.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-bot@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox