[PATCH] iio: imu: adis16400: Check return value of spi_setup()

Salah Triki posted 1 patch 3 weeks, 1 day ago
drivers/iio/imu/adis16400.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
[PATCH] iio: imu: adis16400: Check return value of spi_setup()
Posted by Salah Triki 3 weeks, 1 day ago
In adis16400_initial_setup(), the return value of spi_setup() was ignored.
If SPI configuration fails, the driver would proceed with the
initialization anyway, leading to undefined behavior or silent failures
during device setup.

Check the return value of spi_setup() and return the error code immediately
if it fails.

Fixes: cd888a17f95f ("staging:iio:adis16400: Use adis library")
Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
 drivers/iio/imu/adis16400.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c
index 4842346f9f0c..f51878066b2f 100644
--- a/drivers/iio/imu/adis16400.c
+++ b/drivers/iio/imu/adis16400.c
@@ -420,7 +420,10 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev)
 	else
 		st->adis.spi->max_speed_hz = ADIS16400_SPI_FAST;
 	st->adis.spi->mode = SPI_MODE_3;
-	spi_setup(st->adis.spi);
+
+	ret = spi_setup(st->adis.spi);
+	if (ret)
+		return ret;
 
 	ret = __adis_initial_startup(&st->adis);
 	if (ret)
-- 
2.43.0
Re: [PATCH] iio: imu: adis16400: Check return value of spi_setup()
Posted by Andy Shevchenko 3 weeks, 1 day ago
On Thu, Sep 03, 2026 at 01:27:33PM +0100, Salah Triki wrote:
> In adis16400_initial_setup(), the return value of spi_setup() was ignored.
> If SPI configuration fails, the driver would proceed with the
> initialization anyway, leading to undefined behavior or silent failures
> during device setup.
> 
> Check the return value of spi_setup() and return the error code immediately
> if it fails.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH] iio: imu: adis16400: Check return value of spi_setup()
Posted by Jonathan Cameron 2 weeks, 5 days ago
On Thu, 3 Sep 2026 16:35:35 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Thu, Sep 03, 2026 at 01:27:33PM +0100, Salah Triki wrote:
> > In adis16400_initial_setup(), the return value of spi_setup() was ignored.
> > If SPI configuration fails, the driver would proceed with the
> > initialization anyway, leading to undefined behavior or silent failures
> > during device setup.
> > 
> > Check the return value of spi_setup() and return the error code immediately
> > if it fails.  
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> 

I assume in practice this never fails, so treating this as hardening
rather than an urgent fix.  Applied to the testing branch of iio.git

Thanks,

Jonathan