All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
To: Jon Hunter <jonathanh@nvidia.com>, Wolfram Sang <wsa@the-dreams.de>
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] i2c: core: Add missing of_node_put()
Date: Fri, 15 Apr 2016 17:58:38 +0300	[thread overview]
Message-ID: <5711019E.9020304@mentor.com> (raw)
In-Reply-To: <1460724191-12167-1-git-send-email-jonathanh@nvidia.com>

On 15.04.2016 15:43, Jon Hunter wrote:
> for_each_available_child_of_node performs an of_node_get on each
> iteration, so of_node_put() must be called on each iteration once
> we are finished with the node pointer.

This is wrong, embedded of_get_next_available_child() correctly decrements
ref counter of an examined node.

> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
> ---
>  drivers/i2c/i2c-core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 4979728f7fb2..38f4dae681a9 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -1428,9 +1428,9 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
>  	dev_dbg(&adap->dev, "of_i2c: walking child nodes\n");
>  
>  	for_each_available_child_of_node(adap->dev.of_node, node) {
> -		if (of_node_test_and_set_flag(node, OF_POPULATED))
> -			continue;
> -		of_i2c_register_device(adap, node);
> +		if (!of_node_test_and_set_flag(node, OF_POPULATED))
> +			of_i2c_register_device(adap, node);
> +		of_node_put(node);
>  	}
>  }
>  
> 

--
With best wishes,
Vladimir

WARNING: multiple messages have this Message-ID (diff)
From: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
To: Jon Hunter <jonathanh@nvidia.com>, Wolfram Sang <wsa@the-dreams.de>
Cc: <linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] i2c: core: Add missing of_node_put()
Date: Fri, 15 Apr 2016 17:58:38 +0300	[thread overview]
Message-ID: <5711019E.9020304@mentor.com> (raw)
In-Reply-To: <1460724191-12167-1-git-send-email-jonathanh@nvidia.com>

On 15.04.2016 15:43, Jon Hunter wrote:
> for_each_available_child_of_node performs an of_node_get on each
> iteration, so of_node_put() must be called on each iteration once
> we are finished with the node pointer.

This is wrong, embedded of_get_next_available_child() correctly decrements
ref counter of an examined node.

> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
> ---
>  drivers/i2c/i2c-core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 4979728f7fb2..38f4dae681a9 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -1428,9 +1428,9 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
>  	dev_dbg(&adap->dev, "of_i2c: walking child nodes\n");
>  
>  	for_each_available_child_of_node(adap->dev.of_node, node) {
> -		if (of_node_test_and_set_flag(node, OF_POPULATED))
> -			continue;
> -		of_i2c_register_device(adap, node);
> +		if (!of_node_test_and_set_flag(node, OF_POPULATED))
> +			of_i2c_register_device(adap, node);
> +		of_node_put(node);
>  	}
>  }
>  
> 

--
With best wishes,
Vladimir

  reply	other threads:[~2016-04-15 14:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-15 12:43 [PATCH] i2c: core: Add missing of_node_put() Jon Hunter
2016-04-15 12:43 ` Jon Hunter
2016-04-15 14:58 ` Vladimir Zapolskiy [this message]
2016-04-15 14:58   ` Vladimir Zapolskiy
2016-04-15 15:34   ` Jon Hunter
2016-04-15 15:34     ` Jon Hunter

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=5711019E.9020304@mentor.com \
    --to=vladimir_zapolskiy@mentor.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wsa@the-dreams.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.