Re: [PATCH v4 1/3] iio: adc: at91_adc: fix NULL pointer dereference on trigger remove

From: Andy Shevchenko

Date: Mon Nov 23 2026 - 04:31:57 EST


On Sun, Nov 22, 2026 at 12:21:18AM +0000, Jonathan Cameron wrote:
> On Tue, 17 Nov 2026 18:45:29 +0200
> Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:
> > On Tue, Nov 17, 2026 at 06:44:37PM +0200, Andy Shevchenko wrote:
> > > On Tue, Nov 17, 2026 at 04:05:08PM +0200, Abdelnasser Hussein wrote:

...

> > > > for (i = 0; i < st->caps->trigger_number; i++) {
> > > > + if (!st->trig[i])
> > > > + continue;
> > > > iio_trigger_unregister(st->trig[i]);
> > > > iio_trigger_free(st->trig[i]);
> > > > }
> > >
> > > Yes, but no. Please, rather fix the above mentioned IIO trigger APIs to be
> > > NULL-aware.
> >
> > Actually the iio_trigger_free() is already NULL-aware, so make it only for
> > iio_trigger_unregister().
>
> I'd rather we didn't. Any code that is unregistering a trigger
> that it didn't register is probably really very very buggy.
> I'd like them to crash or at least guarantee that sashiko
> flags it. We could add a warn if it is called on NULL I suppose
> but that is ugly.

Can we add a comment there to avoid making such a change explaining
why we won't iio_trigger_unregister() be NULL-aware?

--
With Best Regards,
Andy Shevchenko