Re: [PATCH v5] iio: imu: kmx61: Use guard(mutex)() over manual locking

From: Jonathan Cameron

Date: Mon May 11 2026 - 13:44:57 EST


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!)

>
> best regards,
> max