From: Matti Vaittinen Date: Mon, 7 Apr 2025 11:36:23 +0000 (+0300) Subject: iio: adc: ti-adc128s052: Use devm_mutex_init() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=804757a221a9258eca90129aff4b136abe335446;p=users%2Fjedix%2Flinux-maple.git iio: adc: ti-adc128s052: Use devm_mutex_init() 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 Link: https://patch.msgid.link/efe4a039e2bfbf4dcf30743f6b7b88fce3b9ee39.1744022065.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index d0702d403fbec..d90a5caa028f0 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -172,7 +172,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); }