lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240211174237.182947-7-jic23@kernel.org>
Date: Sun, 11 Feb 2024 17:42:34 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: linux-iio@...r.kernel.org,
	Rob Herring <robh@...nel.org>,
	Frank Rowand <frowand.list@...il.com>,
	linux-kernel@...r.kernel.org,
	Julia Lawall <Julia.Lawall@...ia.fr>
Cc: Peter Zijlstra <peterz@...radead.org>,
	Nicolas Palix <nicolas.palix@...g.fr>,
	Sumera Priyadarsini <sylphrenadin@...il.com>,
	"Rafael J . Wysocki" <rafael@...nel.org>,
	Len Brown <lenb@...nel.org>,
	linux-acpi@...r.kernel.org,
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Nuno Sá <nuno.sa@...log.com>,
	Jonathan Cameron <Jonathan.Cameron@...wei.com>
Subject: [PATCH 6/8] iio: adc: ad7124: Use for_each_available_child_of_node_scoped()

From: Jonathan Cameron <Jonathan.Cameron@...wei.com>

Avoids the need for manual cleanup of_node_put() in early exits
from the loop.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
---
 drivers/iio/adc/ad7124.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
index b9b206fcd748..67ccdad752c5 100644
--- a/drivers/iio/adc/ad7124.c
+++ b/drivers/iio/adc/ad7124.c
@@ -813,7 +813,6 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
 	struct ad7124_state *st = iio_priv(indio_dev);
 	struct ad7124_channel_config *cfg;
 	struct ad7124_channel *channels;
-	struct device_node *child;
 	struct iio_chan_spec *chan;
 	unsigned int ain[2], channel = 0, tmp;
 	int ret;
@@ -838,24 +837,21 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
 	indio_dev->num_channels = st->num_channels;
 	st->channels = channels;
 
-	for_each_available_child_of_node(np, child) {
+	for_each_available_child_of_node_scoped(np, child) {
 		cfg = &st->channels[channel].cfg;
 
 		ret = of_property_read_u32(child, "reg", &channel);
 		if (ret)
-			goto err;
+			return ret;
 
-		if (channel >= indio_dev->num_channels) {
-			dev_err(indio_dev->dev.parent,
-				"Channel index >= number of channels\n");
-			ret = -EINVAL;
-			goto err;
-		}
+		if (channel >= indio_dev->num_channels)
+			return dev_err_probe(indio_dev->dev.parent, -EINVAL,
+					     "Channel index >= number of channels\n");
 
 		ret = of_property_read_u32_array(child, "diff-channels",
 						 ain, 2);
 		if (ret)
-			goto err;
+			return ret;
 
 		st->channels[channel].nr = channel;
 		st->channels[channel].ain = AD7124_CHANNEL_AINP(ain[0]) |
@@ -880,10 +876,6 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
 	}
 
 	return 0;
-err:
-	of_node_put(child);
-
-	return ret;
 }
 
 static int ad7124_setup(struct ad7124_state *st)
-- 
2.43.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ