Re: [PATCH 5.10 070/161] iio: imu: st_lsm6dsx: fix iio_chan_spec for sensors without event detection

Greg Kroah-Hartman
2026-02-06T11:22:47Z

On Fri, Feb 06, 2026 at 09:17:38AM +0100, Francesco Lavra wrote:
> On Thu, 2026-02-05 at 23:44 +0100, Ben Hutchings wrote:
> > On Wed, 2026-02-04 at 15:38 +0100, Greg Kroah-Hartman wrote:
> > > 5.10-stable review patch.  If anyone has any objections, please let me
> > > know.
> > >
> > > ------------------
> > >
> > > From: Francesco Lavra <flavra@baylibre.com>
> > >
> > > commit c34e2e2d67b3bb8d5a6d09b0d6dac845cdd13fb3 upstream.
> > >
> > > The st_lsm6dsx_acc_channels array of struct iio_chan_spec has a non-
> > > NULL
> > > event_spec field, indicating support for IIO events. However, event
> > > detection is not supported for all sensors, and if userspace tries to
> > > configure accelerometer wakeup events on a sensor device that does not
> > > support them (e.g. LSM6DS0), st_lsm6dsx_write_event() dereferences a
> > > NULL
> > > pointer when trying to write to the wakeup register.
> > > Define an additional struct iio_chan_spec array whose members have a
> > > NULL
> > > event_spec field, and use this array instead of st_lsm6dsx_acc_channels
> > > for
> > > sensors without event detection capability.
> > [...]
> > > @@ -1170,8 +1177,8 @@ static const struct st_lsm6dsx_settings
> > >                 },
> > >                 .channels = {
> > >                         [ST_LSM6DSX_ID_ACC] = {
> > > -                               .chan = st_lsm6dsx_acc_channels,
> > > -                               .len =
> > > ARRAY_SIZE(st_lsm6dsx_acc_channels),
> > > +                               .chan = st_lsm6ds0_acc_channels,
> > > +                               .len =
> > > ARRAY_SIZE(st_lsm6ds0_acc_channels),
> > >                         },
> > >                         [ST_LSM6DSX_ID_GYRO] = {
> > >                                 .chan = st_lsm6dsx_gyro_channels,
> >
> > In the upstream commit the 3rd hunk changed the entry for hardware IDs
> > ST_LSM6DSO16IS_ID and ST_ISM330IS_ID.
> >
> > That entry was added by commit f35e1ee9cb5d "iio: imu: st_lsm6dsx: add
> > support to LSM6DSO16IS" in 6.2.  So in this backport the 3rd hunk is
> > changing configuration for other devices.
> >
> > I think the right thing to do for the 5.10-6.1 branches is to only apply
> > the first 2 hunks.
>
> Good catch. In the 5.10 branch, the third hunk is changing configuration
> for ST_LSM6DSR_ID, ST_ISM330DHCX_ID, and ST_LSM6DSRX_ID, none of which
> should have their configuration changed; so only the first two hunks should
> be applied.

Oh that's crazy. I stared at this for a long time as the patches really
look "identical" when it comes to the original one. You have no context
for what entry is associated with what "configuration" as these
structures are huge!

I'll just drop this patch entirely from all of these queues and wait for
someone to send me a version that they "know" is correct.

thanks,

greg k-h