RE: [PATCH 01/10] iio: imu: adis: Clear pointers after freeing in adis_update_scan_mode()
From: Sabau, Radu bogdan
Date: Mon Nov 23 2026 - 06:43:08 EST
> -----Original Message-----
> From: Jonathan Cameron <jic23@xxxxxxxxxx>
> Sent: Sunday, November 22, 2026 12:27 AM
...
> > adis_update_scan_mode() frees both adis->xfer and adis->buffer at the
> > start of a scan mode update without clearing either pointer to NULL.
> >
> > In both adis_update_scan_mode_burst() and the non-burst path, adis->xfer
> > is allocated before adis->buffer. If the adis->xfer allocation fails,
> > the function returns -ENOMEM while adis->buffer still holds the freed
> > pointer from the previous scan configuration, causing a double-free on
> > the next scan mode update or during device teardown in
> > adis_buffer_cleanup().
> >
> > Clear both pointers immediately after freeing them.
> >
> > Fixes: aacff892cbd5 ("staging:iio:adis: Preallocate transfer message")
> > Closes: https://urldefense.com/v3/__https://sashiko.dev/*/bug/linux-
> 966f0cd4-488a-4d69-b8a5-
> 449c751365d2__;Iw!!A3Ni8CS0y2Y!4i5qWTMsElPdtLCR9XOmFReBGPm1E4-
> QuiQgnUxmuWq60Jc8yaSFDtSw9P02GhSGKQANu9d92G3pXg$
> > Cc: stable@xxxxxxxxxxxxxxx
> > Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
>
> Seems good to me. Given Radu has a bunch of work in flight on around
> the adis drivers and lib. +CC Radu to take a look before I pick this up.
Hi Jonathan, Lee,
The change looks good to me.
I tested it on an ADIS16577-2 (adis16475 driver) on a RPi4, since I have
the setup for testing those FIFO patches, too. Repeated buffer enable/disable
with different channel masks, and unbind/rebind of the device with a capture
after each rebind. No errors or warnings in the kernel log.
Reviewed-by: Radu Sabau <radu.sabau@xxxxxxxxxx>
Thanks,
Radu