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

Jonathan Cameron jic23 at kernel.org
Sat Nov 21 16:21:18 PST 2026


On Tue, 17 Nov 2026 18:45:29 +0200
Andy Shevchenko <andriy.shevchenko at intel.com> 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.

I'd rather deal with this by fixing at source. That doesn't mean
papering over it except as a potential easy to backport change
which is the intent of this one.  It think the description should
call that out though. Something like

"Make a minimal fix to simplify backporting.  Moving over to
 device managed cleanup will shortly remove this code."

Jonathan

> 
> 




More information about the linux-arm-kernel mailing list