linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] iio: adc: ti-ads1015: add missing of_node_put() in ads1015_get_channels_config_of()
@ 2016-08-26 14:31 Wei Yongjun
  2016-08-29 18:51 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2016-08-26 14:31 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Giorgio Dal Molin, Daniel Baluta,
	Matt Ranostay, Gregor Boirie, Crt Mori
  Cc: Wei Yongjun, linux-iio

From: Wei Yongjun <weiyongjun1@huawei.com>

When terminating for_each_child_of_node() iteration with
break or return, of_node_put() should be used to prevent
stale device node references from being left behind.

This is detected by Coccinelle semantic patch.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/iio/adc/ti-ads1015.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
index 066abaf..cde6f13 100644
--- a/drivers/iio/adc/ti-ads1015.c
+++ b/drivers/iio/adc/ti-ads1015.c
@@ -522,6 +522,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client)
 			if (pga > 6) {
 				dev_err(&client->dev, "invalid gain on %s\n",
 					node->full_name);
+				of_node_put(node);
 				return -EINVAL;
 			}
 		}
@@ -532,6 +533,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client)
 				dev_err(&client->dev,
 					"invalid data_rate on %s\n",
 					node->full_name);
+				of_node_put(node);
 				return -EINVAL;
 			}
 		}

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

* Re: [PATCH -next] iio: adc: ti-ads1015: add missing of_node_put() in ads1015_get_channels_config_of()
  2016-08-26 14:31 [PATCH -next] iio: adc: ti-ads1015: add missing of_node_put() in ads1015_get_channels_config_of() Wei Yongjun
@ 2016-08-29 18:51 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2016-08-29 18:51 UTC (permalink / raw)
  To: Wei Yongjun, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Giorgio Dal Molin, Daniel Baluta,
	Matt Ranostay, Gregor Boirie, Crt Mori
  Cc: Wei Yongjun, linux-iio

On 26/08/16 15:31, Wei Yongjun wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> When terminating for_each_child_of_node() iteration with
> break or return, of_node_put() should be used to prevent
> stale device node references from being left behind.
> 
> This is detected by Coccinelle semantic patch.
> 
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Thanks,

Applied to the togreg branch of iio.git. Initially pushed out
as testing for the autobuilders to play with it.

Jonathan
> ---
>  drivers/iio/adc/ti-ads1015.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
> index 066abaf..cde6f13 100644
> --- a/drivers/iio/adc/ti-ads1015.c
> +++ b/drivers/iio/adc/ti-ads1015.c
> @@ -522,6 +522,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client)
>  			if (pga > 6) {
>  				dev_err(&client->dev, "invalid gain on %s\n",
>  					node->full_name);
> +				of_node_put(node);
>  				return -EINVAL;
>  			}
>  		}
> @@ -532,6 +533,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client)
>  				dev_err(&client->dev,
>  					"invalid data_rate on %s\n",
>  					node->full_name);
> +				of_node_put(node);
>  				return -EINVAL;
>  			}
>  		}
> 
> 
> 


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

end of thread, other threads:[~2016-08-29 18:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-26 14:31 [PATCH -next] iio: adc: ti-ads1015: add missing of_node_put() in ads1015_get_channels_config_of() Wei Yongjun
2016-08-29 18:51 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).