All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Poirier <benjamin.poirier@gmail.com>
To: Wang Ming <machel@vivo.com>
Cc: Sunil Goutham <sgoutham@marvell.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, opensource.kernel@vivo.com
Subject: Re: [PATCH net v2] net:thunderx:Fix resource leaks in device_for_each_child_node() loops
Date: Wed, 5 Jul 2023 15:29:19 -0400	[thread overview]
Message-ID: <ZKXEj6p/xkA+1yM4@d3> (raw)
In-Reply-To: <20230705143507.4120-1-machel@vivo.com>

On 2023-07-05 22:34 +0800, Wang Ming wrote:
> The device_for_each_child_node() loop in
> bgx_init_of_phy() function should have
> wnode_handle_put() before break
 ^
 fwnode_handle_put()

> which could avoid resource leaks.
> This patch could fix this bug.
> 
> Signed-off-by: Wang Ming <machel@vivo.com>
> ---
>  drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
> index a317feb8decb..dad32d36a015 100644
> --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
> +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
> @@ -1478,8 +1478,10 @@ static int bgx_init_of_phy(struct bgx *bgx)
>  		 * cannot handle it, so exit the loop.
>  		 */
>  		node = to_of_node(fwn);
> -		if (!node)
> +		if (!node) {
> +			fwnode_handle_put(fwn);
>  			break;
> +		}

Fixes: eee326fd8334 ("net: thunderx: bgx: Use standard firmware node infrastructure.")
?

>  
>  		of_get_mac_address(node, bgx->lmac[lmac].mac);
>  
> @@ -1503,6 +1505,7 @@ static int bgx_init_of_phy(struct bgx *bgx)
>  		lmac++;
>  		if (lmac == bgx->max_lmac) {
>  			of_node_put(node);
> +			fwnode_handle_put(fwn);

\ fwnode_handle_put
	\ of_fwnode_put
		of_node_put(to_of_node(fwnode));

With your patch, there are now two references released on 'node' (two
of_node_put(node) calls).
One reference is from device_for_each_child_node(), where was the other
reference taken?

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Benjamin Poirier <benjamin.poirier@gmail.com>
To: Wang Ming <machel@vivo.com>
Cc: Sunil Goutham <sgoutham@marvell.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, opensource.kernel@vivo.com
Subject: Re: [PATCH net v2] net:thunderx:Fix resource leaks in device_for_each_child_node() loops
Date: Wed, 5 Jul 2023 15:29:19 -0400	[thread overview]
Message-ID: <ZKXEj6p/xkA+1yM4@d3> (raw)
In-Reply-To: <20230705143507.4120-1-machel@vivo.com>

On 2023-07-05 22:34 +0800, Wang Ming wrote:
> The device_for_each_child_node() loop in
> bgx_init_of_phy() function should have
> wnode_handle_put() before break
 ^
 fwnode_handle_put()

> which could avoid resource leaks.
> This patch could fix this bug.
> 
> Signed-off-by: Wang Ming <machel@vivo.com>
> ---
>  drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
> index a317feb8decb..dad32d36a015 100644
> --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
> +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
> @@ -1478,8 +1478,10 @@ static int bgx_init_of_phy(struct bgx *bgx)
>  		 * cannot handle it, so exit the loop.
>  		 */
>  		node = to_of_node(fwn);
> -		if (!node)
> +		if (!node) {
> +			fwnode_handle_put(fwn);
>  			break;
> +		}

Fixes: eee326fd8334 ("net: thunderx: bgx: Use standard firmware node infrastructure.")
?

>  
>  		of_get_mac_address(node, bgx->lmac[lmac].mac);
>  
> @@ -1503,6 +1505,7 @@ static int bgx_init_of_phy(struct bgx *bgx)
>  		lmac++;
>  		if (lmac == bgx->max_lmac) {
>  			of_node_put(node);
> +			fwnode_handle_put(fwn);

\ fwnode_handle_put
	\ of_fwnode_put
		of_node_put(to_of_node(fwnode));

With your patch, there are now two references released on 'node' (two
of_node_put(node) calls).
One reference is from device_for_each_child_node(), where was the other
reference taken?

  parent reply	other threads:[~2023-07-05 19:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-05 14:34 [PATCH net v2] net:thunderx:Fix resource leaks in device_for_each_child_node() loops Wang Ming
2023-07-05 14:34 ` Wang Ming
2023-07-05 19:10 ` Leon Romanovsky
2023-07-05 19:10   ` Leon Romanovsky
2023-07-06 12:34   ` 回复: " 王明-软件底层技术部
2023-07-06 12:34     ` 王明-软件底层技术部
2023-07-05 19:29 ` Benjamin Poirier [this message]
2023-07-05 19:29   ` Benjamin Poirier
2023-07-06  3:40   ` 回复: " 王明-软件底层技术部
2023-07-06  3:40     ` 王明-软件底层技术部
2023-07-05 19:32 ` [PATCH net v2] net: thunderx: Fix resource leaks in a device_for_each_child_node() loop Markus Elfring
2023-07-05 19:32   ` Markus Elfring
2023-07-06  3:34   ` 回复: " 王明-软件底层技术部
2023-07-06  3:34     ` 王明-软件底层技术部
2023-07-06 11:46     ` Markus Elfring
2023-07-06 11:46       ` Markus Elfring

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=ZKXEj6p/xkA+1yM4@d3 \
    --to=benjamin.poirier@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=machel@vivo.com \
    --cc=netdev@vger.kernel.org \
    --cc=opensource.kernel@vivo.com \
    --cc=pabeni@redhat.com \
    --cc=sgoutham@marvell.com \
    /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.