Re: [PATCH v6 06/10] iio: adc: ad_sigma_delta: Fix a race condition

Andy Shevchenko
2024-12-09T00:53:19Z

On Sun, Dec 8, 2024 at 8:23 PM Jonathan Cameron <jic23@kernel.org> wrote:
> On Sun, 8 Dec 2024 15:05:38 +0200
> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> > On Sun, Dec 8, 2024 at 2:42 PM Jonathan Cameron <jic23@kernel.org> wrote:
> > > On Fri, 6 Dec 2024 18:28:38 +0100

...

> > > From sparse.
> > >
> > > drivers/iio/adc/ad_sigma_delta.c:205:13: warning: context imbalance in 'ad_sd_disable_irq' - wrong count at exit
> > > drivers/iio/adc/ad_sigma_delta.c:218:13: warning: context imbalance in 'ad_sd_enable_irq' - wrong count at exit
> > >
> > > I saw your discussion with Linus on this...
> > >
> > > https://lore.kernel.org/all/CAHk-=wiVDZejo_1BhOaR33qb=pny7sWnYtP4JUbRTXkXCkW6jA@mail.gmail.com/
> > >
> > > So I guess we just treat that as a false positive and move on.
> >
> > I'm wondering if sparse annotation __acquire and __release may help here...
>
> The complaint is (I think) about guard(spinlock_irqsave)
> so I'm not immediately sure how.

In cases like

if (x)
lock();
...do smth...
if (x)
unlock()

Those annotations give sparse hints that locking is balanced. That is
why I was thinking it may help guard as well.

--
With Best Regards,
Andy Shevchenko