mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Matti Vaittinen <mazziesaccount@gmail.com>,
	Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Matti Vaittinen <mazziesaccount@gmail.com>,
	Nuno Sa <nuno.sa@analog.com>,
	David Lechner <dlechner@baylibre.com>,
	Javier Carrasco <javier.carrasco.cruz@gmail.com>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 4/7] iio: adc: ti-adc128s052: Use devm_mutex_init()
Date: Wed, 2 Apr 2025 09:09:38 +0300	[thread overview]
Message-ID: <469d5ab906c3c723cb657bbcf1ce200fae255ead.1743573284.git.mazziesaccount@gmail.com> (raw)
In-Reply-To: <cover.1743573284.git.mazziesaccount@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 947 bytes --]

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 --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);
 }
-- 
2.49.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2025-04-02  6:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-02  6:07 [PATCH v2 0/7] Support ROHM BD79104 ADC Matti Vaittinen
2025-04-02  6:08 ` [PATCH v2 1/7] dt-bindings: " Matti Vaittinen
2025-04-02  6:09 ` [PATCH v2 2/7] iio: adc: ti-adc128s052: Simplify using be16_to_cpu() Matti Vaittinen
2025-04-02 21:04   ` David Lechner
2025-04-03  5:16     ` Matti Vaittinen
2025-04-05 17:29       ` Jonathan Cameron
2025-04-07  5:23         ` Matti Vaittinen
2025-04-07 18:49           ` Jonathan Cameron
2025-04-02  6:09 ` [PATCH v2 3/7] iio: adc: ti-adc128s052: Be consistent with arrays Matti Vaittinen
2025-04-02  6:09 ` Matti Vaittinen [this message]
2025-04-02  6:09 ` [PATCH v2 5/7] iio: adc: ti-adc128s052: Simplify using guard(mutex) Matti Vaittinen
2025-04-02  6:10 ` [PATCH v2 6/7] iio: adc: ti-adc128s052: Support ROHM BD79104 Matti Vaittinen
2025-04-02  6:10 ` [PATCH RFC v2 7/7] iio: ti-adc128s052: Drop variable vref Matti Vaittinen
2025-04-02 20:49   ` David Lechner
2025-04-03  5:18     ` Matti Vaittinen
2025-04-05 16:25     ` Jonathan Cameron
2025-04-02  6:19 ` [PATCH v2 0/7] Support ROHM BD79104 ADC Matti Vaittinen
2025-04-05 17:36   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=469d5ab906c3c723cb657bbcf1ce200fae255ead.1743573284.git.mazziesaccount@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matti.vaittinen@fi.rohmeurope.com \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®