diff mbox series

[v2,4/7] iio: adc: ti-adc128s052: Use devm_mutex_init()

Message ID 469d5ab906c3c723cb657bbcf1ce200fae255ead.1743573284.git.mazziesaccount@gmail.com (mailing list archive)
State New
Headers show
Series Support ROHM BD79104 ADC | expand

Commit Message

Matti Vaittinen April 2, 2025, 6:09 a.m. UTC
Quoting Jonathan:
"Whilst it doesn't bring huge advantage, now we have devm_mutex_init()
it seems reasonable to use it and maybe catch a use after free for the
lock"

Switch to use devm_mutex_init() while working on this file.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>

---
v1 => v2:
 - Check the return value for the devm_mutex_init()
---
 drivers/iio/adc/ti-adc128s052.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
index 861a35169196..bef2d29c06af 100644
--- a/drivers/iio/adc/ti-adc128s052.c
+++ b/drivers/iio/adc/ti-adc128s052.c
@@ -173,7 +173,9 @@  static int adc128_probe(struct spi_device *spi)
 	if (ret)
 		return ret;
 
-	mutex_init(&adc->lock);
+	ret = devm_mutex_init(&spi->dev, &adc->lock);
+	if (ret)
+		return ret;
 
 	return devm_iio_device_register(&spi->dev, indio_dev);
 }