Skip to content

Commit 6b39824

Browse files
Pavel Zhigulinjic23
authored andcommitted
iio: adc: ad7280a: handle spi_setup() errors in probe()
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: 2051f25 ("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>
1 parent dbdb442 commit 6b39824

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/iio/adc/ad7280a.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,9 @@ static int ad7280_probe(struct spi_device *spi)
10241024

10251025
st->spi->max_speed_hz = AD7280A_MAX_SPI_CLK_HZ;
10261026
st->spi->mode = SPI_MODE_1;
1027-
spi_setup(st->spi);
1027+
ret = spi_setup(st->spi);
1028+
if (ret < 0)
1029+
return ret;
10281030

10291031
st->ctrl_lb = FIELD_PREP(AD7280A_CTRL_LB_ACQ_TIME_MSK, st->acquisition_time) |
10301032
FIELD_PREP(AD7280A_CTRL_LB_THERMISTOR_MSK, st->thermistor_term_en);

0 commit comments

Comments
 (0)