Skip to contentSkip to conversation

iio: imu: adis16400: Check return value of spi_setup()

PATCH In review Salah Triki 3 participants 3 messages Sep 3 – Sep 7

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: imu: adis16400: Check return value of spi_setup()

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")
---
 drivers/iio/imu/adis16400.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iio/imu/adis16400.c +4 -1
index 4842346f9f0c..f51878066b2f 100644
@@ -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)
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Salah Triki

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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#2 lore raw
Quoted 11 lines · On Thu, 3 Sep 2026 16:35:35 +0300 Andy Shevchenko…
Quoted 7 lines · Salah Triki

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.

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