Re: [PATCH v8 2/9] iio: accel: mma8452: Fix use-after-free bug in error error path
From: Esben Haabendal
Date: Mon Sep 14 2026 - 02:50:18 EST
"Jonathan Cameron" <jic23@xxxxxxxxxx> writes:
> On Mon, 07 Sep 2026 16:50:57 +0200
> Esben Haabendal <esben@xxxxxxxxxx> wrote:
>
>> If mma8452_probe() fails in iio_device_register() or later, we could end up
>> with runtime suspend callback being called with a now freed device pointer.
>>
>> Fixes: 96c0cb2bbfe0 ("iio: mma8452: add support for runtime power management")
>> Cc: stable@xxxxxxxxxxxxxxx
>> Reviewed-by: Joshua Crofts <joshua.crofts1@xxxxxxxxx>
>> Signed-off-by: Esben Haabendal <esben@xxxxxxxxxx>
>
> Sashiko calls out some preexisting stuff that is worth a look
> https://sashiko.dev/#/patchset/20260907-mma8452-open-drain-v8-0-c17407e22118%40geanix.com
Yes. And I have a follow-up patch series where I try to address
basically everything sashiko-bot has raised concerns for.
Given the rather large number of issues, and the corresponding large
number of changes needed, I am not planning on adding them to this
series.
> Why freefall mode is set after the iio_device_register() is indeed an interesting
> question. Any idea?
I cannot find any good reason for doing it like that. I am moving the
iio_device_register() call to be the last thing done in .probe() in the
follow-up series, so that the device is fully ready before we expose
user-space API for it.
> As far as it goes this patch is fine. I'm not sure about the other sashiko
> comment about making sure the device is suspended. Given pm_runtime_set_active()
> is called I would assume that one of the register sequences has indeed
> turned on the device (maybe the reset?) and we should be turning it off again.
There is quite a number of issues with runtime pm in this driver. I look
forward to getting feedback to the changes I have made to them :)
/Esben