public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: adc: gyroadc: fix leak of device node iterator
@ 2020-09-26 10:45 Tobias Jordan
  2020-09-26 14:47 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Jordan @ 2020-09-26 10:45 UTC (permalink / raw)
  To: linux-iio, linux-kernel
  Cc: Marek Vasut, Jonathan Cameron, Lars-Peter Clausen,
	Peter Meerwald-Stadler

Add missing of_node_put calls for the error paths of the
for_each_child_of_node loop in rcar_gyroadc_parse_subdevs.

Thought about adding an "goto err_of_node_put" instead, but as the error
paths are quite divergent, I'm not sure if that wouldn't complicate
things.

Fixes: 059c53b32329 ("iio: adc: Add Renesas GyroADC driver")
Signed-off-by: Tobias Jordan <kernel@cdqe.de>
---
 drivers/iio/adc/rcar-gyroadc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c
index dcaefc108ff6..3746b0276b80 100644
--- a/drivers/iio/adc/rcar-gyroadc.c
+++ b/drivers/iio/adc/rcar-gyroadc.c
@@ -357,6 +357,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
 			num_channels = ARRAY_SIZE(rcar_gyroadc_iio_channels_3);
 			break;
 		default:
+			of_node_put(child);
 			return -EINVAL;
 		}
 
@@ -374,6 +375,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
 				dev_err(dev,
 					"Failed to get child reg property of ADC \"%pOFn\".\n",
 					child);
+				of_node_put(child);
 				return ret;
 			}
 
@@ -382,6 +384,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
 				dev_err(dev,
 					"Only %i channels supported with %pOFn, but reg = <%i>.\n",
 					num_channels, child, reg);
+				of_node_put(child);
 				return -EINVAL;
 			}
 		}
@@ -391,6 +394,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
 			dev_err(dev,
 				"Channel %i uses different ADC mode than the rest.\n",
 				reg);
+			of_node_put(child);
 			return -EINVAL;
 		}
 
@@ -401,6 +405,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
 		if (IS_ERR(vref)) {
 			dev_dbg(dev, "Channel %i 'vref' supply not connected.\n",
 				reg);
+			of_node_put(child);
 			return PTR_ERR(vref);
 		}
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-26 14:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-26 10:45 [PATCH] iio: adc: gyroadc: fix leak of device node iterator Tobias Jordan
2020-09-26 14:47 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox