Re: [PATCH] staging: iio: adc: ad7816: Protect sysfs attributes with mutex

From: Jonathan Cameron

Date: Sat Sep 19 2026 - 21:05:50 EST


On Sat, 19 Sep 2026 13:44:44 +0300
Dan Carpenter <error27@xxxxxxxxx> wrote:

> On Sat, Sep 19, 2026 at 11:55:13AM +0300, Abdelnasser Hussein wrote:
> > The sysfs store functions (ad7816_store_mode and ad7816_store_channel)
> > modify the device state and toggle GPIO pins. If accessed concurrently
> > by userspace during an ongoing SPI transfer, this could corrupt the
> > SPI transaction.
> >
> > Add the existing chip->lock guard to these functions to serialize
> > access and prevent race conditions.
> >
> > Suggested-by: Joshua Crofts <joshua.crofts1@xxxxxxxxx>
> > Signed-off-by: Abdelnasser Hussein <abdelnasserhussein11@xxxxxxxxx>
>
> Add a Fixes tag.

Hmm - this is a follow up for a few missed cases. The original patch
should probably have had a fixes tag as well even though it's in staging
and the bug goes back probably a decade or more. Ah well, Abdelnasser,
add one here anyway and send a v2 with the spacing Joshua asked for.

Thanks,

Jonathan

>
> regards,
> dan carpenter
>