Re: [PATCH v4] iio: common: st_sensors: Fix use of uninitialize device structs
From: Jonathan Cameron
Date: Sat Jun 28 2025 - 13:12:01 EST
On Mon, 23 Jun 2025 15:27:44 +0200
Maud Spierings <maudspierings@xxxxxxxxxxxxxx> wrote:
> On 5/31/25 19:03, Jonathan Cameron wrote:
> > On Tue, 27 May 2025 08:36:08 +0200
> > Maud Spierings via B4 Relay <devnull+maudspierings.gocontroll.com@xxxxxxxxxx> wrote:
> >
> >> From: Maud Spierings <maudspierings@xxxxxxxxxxxxxx>
> >>
> >> Throughout the various probe functions &indio_dev->dev is used before it
> >> is initialized. This caused a kernel panic in st_sensors_power_enable()
> >> when the call to devm_regulator_bulk_get_enable() fails and then calls
> >> dev_err_probe() with the uninitialized device.
> >>
> >> This seems to only cause a panic with dev_err_probe(), dev_err(),
> >> dev_warn() and dev_info() don't seem to cause a panic, but are fixed
> >> as well.
> >>
> >> The issue is reported and traced here: [1]
> >>
> >> Link: https://lore.kernel.org/all/AM7P189MB100986A83D2F28AF3FFAF976E39EA@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/ [1]
> >> Cc: stable@xxxxxxxxxxxxxxx
> >> Signed-off-by: Maud Spierings <maudspierings@xxxxxxxxxxxxxx>
> >> ---
> >> When I search for general &indio_dev->dev usage, I see quite a lot more
> >> hits, but I am not sure if there are issues with those too.
> >
> > For probe error messages I'd like to see them all moved over to the parent
> > device but more generally it may make sense to use indio_dev->dev
> >
> > As per the earlier discussion I still wonder if we should harden
> > device_set_deferred_reason() against this condition just as a
> > defense in depth thing.
> >
> > Anyhow, this is a good change in any case. Applied to the fixes-togreg-for-6.16 branch
> > that I'll rebase on rc1 once available.
>
> Hi, I've not seen this patch pass by in the stable tree or will this get
> submitted for 6.17-rc1?
I'm just being a bit slow this cycle. I'll send a fixes pull request out
soonish then it'll go into 6.16-rcX and after that get pulled back into stable.
Jonathan
>
> Sorry if I am being too impatient.
>
> kind regards,
> Maud