summaryrefslogtreecommitdiff
path: root/drivers/iio
diff options
context:
space:
mode:
authorPavel Zhigulin <Pavel.Zhigulin@kaspersky.com>2025-11-14 18:13:01 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-01-30 12:28:41 +0300
commitc7ee18052d001da1031a86076a53ddc9f9bbfc4d (patch)
treef0ee33aef19bb856974912c6e0749a83d3e3b8a6 /drivers/iio
parent4d60ffcdedfe2cdb68a1cde19bb292bc67451629 (diff)
downloadlinux-c7ee18052d001da1031a86076a53ddc9f9bbfc4d.tar.xz
iio: adc: ad7280a: handle spi_setup() errors in probe()
[ Upstream commit 6b39824ac4c15783787e6434449772bfb2e31214 ] The probe() function ignored the return value of spi_setup(), leaving SPI configuration failures undetected. If spi_setup() fails, the driver should stop initialization and propagate the error to the caller. Add proper error handling: check the return value of spi_setup() and return it on failure. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 2051f25d2a26 ("iio: adc: New driver for AD7280A Lithium Ion Battery Monitoring System") Signed-off-by: Pavel Zhigulin <Pavel.Zhigulin@kaspersky.com> Reviewed-by: Marcelo Schmitt <marcelo.schmitt@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/adc/ad7280a.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/iio/adc/ad7280a.c b/drivers/iio/adc/ad7280a.c
index 37522dca2c7c..01d5719aa3ea 100644
--- a/drivers/iio/adc/ad7280a.c
+++ b/drivers/iio/adc/ad7280a.c
@@ -1026,7 +1026,9 @@ static int ad7280_probe(struct spi_device *spi)
st->spi->max_speed_hz = AD7280A_MAX_SPI_CLK_HZ;
st->spi->mode = SPI_MODE_1;
- spi_setup(st->spi);
+ ret = spi_setup(st->spi);
+ if (ret < 0)
+ return ret;
st->ctrl_lb = FIELD_PREP(AD7280A_CTRL_LB_ACQ_TIME_MSK, st->acquisition_time) |
FIELD_PREP(AD7280A_CTRL_LB_THERMISTOR_MSK, st->thermistor_term_en);