diff mbox series

[v2,11/46] mfd: ti_am335x_tscadc: Ensure a balanced number of node get/put

Message ID 20210902215144.507243-12-miquel.raynal@bootlin.com
State New
Headers show
Series TI AM437X ADC1 | expand

Commit Message

Miquel Raynal Sept. 2, 2021, 9:51 p.m. UTC
of_node_put() should be called after a successful of_get_child_by_name().

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Jonathan Cameron Sept. 5, 2021, 12:06 p.m. UTC | #1
On Thu,  2 Sep 2021 23:51:09 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> of_node_put() should be called after a successful of_get_child_by_name().
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
I suppose you 'could' move this to the front of the series as a fix, but
it's probably not critical so fine to keep it here.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/mfd/ti_am335x_tscadc.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 858bd22c60f0..763bbc33fc3f 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -134,6 +134,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	node = of_get_child_by_name(pdev->dev.of_node, "tsc");
>  	of_property_read_u32(node, "ti,wires", &tsc_wires);
>  	of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
> +	of_node_put(node);
>  
>  	node = of_get_child_by_name(pdev->dev.of_node, "adc");
>  	of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
> @@ -141,10 +142,13 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  		if (val > 7) {
>  			dev_err(&pdev->dev, " PIN numbers are 0..7 (not %d)\n",
>  				val);
> +			of_node_put(node);
>  			return -EINVAL;
>  		}
>  	}
>  
> +	of_node_put(node);
> +
>  	total_channels = tsc_wires + adc_channels;
>  	if (total_channels > 8) {
>  		dev_err(&pdev->dev, "Number of i/p channels more than 8\n");
diff mbox series

Patch

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 858bd22c60f0..763bbc33fc3f 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -134,6 +134,7 @@  static	int ti_tscadc_probe(struct platform_device *pdev)
 	node = of_get_child_by_name(pdev->dev.of_node, "tsc");
 	of_property_read_u32(node, "ti,wires", &tsc_wires);
 	of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
+	of_node_put(node);
 
 	node = of_get_child_by_name(pdev->dev.of_node, "adc");
 	of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
@@ -141,10 +142,13 @@  static	int ti_tscadc_probe(struct platform_device *pdev)
 		if (val > 7) {
 			dev_err(&pdev->dev, " PIN numbers are 0..7 (not %d)\n",
 				val);
+			of_node_put(node);
 			return -EINVAL;
 		}
 	}
 
+	of_node_put(node);
+
 	total_channels = tsc_wires + adc_channels;
 	if (total_channels > 8) {
 		dev_err(&pdev->dev, "Number of i/p channels more than 8\n");