netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: hns: hns_enet: Add of_node_put in hns_nic_dev_probe()
@ 2019-08-15  6:28 Nishka Dasgupta
  2019-08-15  9:59 ` Yonglong Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Nishka Dasgupta @ 2019-08-15  6:28 UTC (permalink / raw)
  To: yisen.zhuang, salil.mehta, davem, netdev; +Cc: Nishka Dasgupta

The local variable ae_node in function hns_nic_dev_probe takes the
return value of of_parse_phandle, which gets a node but does not put it.
This may cause a memory leak. Hence put ae_node after the last time it
is invoked.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 2235dd55fab2..b26e84929e1e 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -2309,6 +2309,7 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
 			goto out_read_prop_fail;
 		}
 		priv->fwnode = &ae_node->fwnode;
+		of_node_put(ae_node);
 	} else if (is_acpi_node(dev->fwnode)) {
 		struct fwnode_reference_args args;
 
-- 
2.19.1


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

* Re: [PATCH] net: hns: hns_enet: Add of_node_put in hns_nic_dev_probe()
  2019-08-15  6:28 [PATCH] net: hns: hns_enet: Add of_node_put in hns_nic_dev_probe() Nishka Dasgupta
@ 2019-08-15  9:59 ` Yonglong Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Yonglong Liu @ 2019-08-15  9:59 UTC (permalink / raw)
  To: Nishka Dasgupta, yisen.zhuang, salil.mehta, davem, netdev



On 2019/8/15 14:28, Nishka Dasgupta wrote:
> The local variable ae_node in function hns_nic_dev_probe takes the
> return value of of_parse_phandle, which gets a node but does not put it.
> This may cause a memory leak. Hence put ae_node after the last time it
> is invoked.
> Issue found with Coccinelle.
> 
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---
>  drivers/net/ethernet/hisilicon/hns/hns_enet.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> index 2235dd55fab2..b26e84929e1e 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
> @@ -2309,6 +2309,7 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
>  			goto out_read_prop_fail;
>  		}
>  		priv->fwnode = &ae_node->fwnode;
> +		of_node_put(ae_node);
>  	} else if (is_acpi_node(dev->fwnode)) {
>  		struct fwnode_reference_args args;
>  
> 

Hi, Nishka:
This patch is wrong, we put the node in hns_nic_dev_remove().

The following patch had solved this problem:
263c6d75f9a5 (net: hns: Fix for missing of_node_put() after of_parse_phandle())


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

end of thread, other threads:[~2019-08-15  9:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-15  6:28 [PATCH] net: hns: hns_enet: Add of_node_put in hns_nic_dev_probe() Nishka Dasgupta
2019-08-15  9:59 ` Yonglong Liu

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).