Re: [PATCH v5] iio: imu: kmx61: Use guard(mutex)() over manual locking
From: Maxwell Doose
Date: Mon May 11 2026 - 13:33:07 EST
On Mon, May 11, 2026 at 12:17 PM Jonathan Cameron <jic23@xxxxxxxxxx> wrote:
>
> On Fri, 8 May 2026 08:03:45 -0500
> Maxwell Doose <m32285159@xxxxxxxxx> wrote:
>
> > Hi Jonathan,
> >
> > On Thu, May 7, 2026 at 5:33 PM Maxwell Doose <m32285159@xxxxxxxxx> wrote:
> > >
> > [snip]
> > > @@ -945,29 +942,26 @@ static int kmx61_write_event_config(struct iio_dev *indio_dev,
> > > if (state && data->ev_enable_state)
> > > return 0;
> > >
> > > - mutex_lock(&data->lock);
> > > + guard(mutex)(&data->lock);
> > >
> >
> > Correct me if I'm wrong but this looks like a TOCTOU race, was
> > reported by sashiko at
> > https://sashiko.dev/#/patchset/20260507223337.48437-1-m32285159%40gmail.com.
> > If this is a confirmed race I'll get a fix out this evening.
> Indeed looks like a correct report.
>
> Take your time though. I'm swamped anyway so will be a while before
> I get to any new patches (probably!)
>
Alrighty sounds good. Dunno if we merge this or not and then send the
fix just in case or if I base it off of the original. Former seems
preferable.
best regards,
max
> >
> > best regards,
> > max
>