Skip to contentSkip to conversation

ASoC: cs35l45: Check spi_setup() return value

PATCH New Alex Kazinsky 1 participant 1 message Nov 13

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

PATCH 1/1 ASoC: cs35l45: Check spi_setup() return value

The SPI probe ignores errors from spi_setup() after updating the maximum bus frequency. If setup fails, initialization continues and accesses the device without ensuring that the SPI configuration succeeded.

Check the return value and abort probe on failure, propagating the original error.

Found by Linux Verification Center (linuxtesting.org) with SVACE static analysis tool.

Fixes 74b14e2850a3 ("ASoC: cs35l45: DSP Support")
---
 sound/soc/codecs/cs35l45-spi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/codecs/cs35l45-spi.c +3 -1
index 76f46dc5ab2c..dcef36d31c45 100644
@@ -24,7 +24,9 @@ static int cs35l45_spi_probe(struct spi_device *spi)
 		return -ENOMEM;
 
 	spi->max_speed_hz = CS35L45_SPI_MAX_FREQ;
-	spi_setup(spi);
+	ret = spi_setup(spi);
+	if (ret)
+		return ret;
 
 	spi_set_drvdata(spi, cs35l45);
 	cs35l45->regmap = devm_regmap_init_spi(spi, &cs35l45_spi_regmap);
Signature · 1 line
2.56.0