[net] net: qcom/emac: Add missing of_node_put()

Message ID 20180611130345.15172-1-yuehaibing@huawei.com
State Accepted
Delegated to: David Miller
Headers show
Series
  • [net] net: qcom/emac: Add missing of_node_put()
Related show

Commit Message

YueHaibing June 11, 2018, 1:03 p.m.
Add missing of_node_put() call for device node returned by
of_parse_phandle().

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Timur Tabi June 12, 2018, 2:03 a.m. | #1
On 6/11/18 8:03 AM, YueHaibing wrote:
> Add missing of_node_put() call for device node returned by
> of_parse_phandle().

Hmmmm... This shouldn't be necessary.  I was very careful with calls to 
of_node_put().  Give me a day or two to confirm, please.
Timur Tabi June 13, 2018, 8:45 p.m. | #2
On 06/11/2018 08:03 AM, YueHaibing wrote:
> Add missing of_node_put() call for device node returned by
> of_parse_phandle().
> 
> Signed-off-by: YueHaibing<yuehaibing@huawei.com>

Acked-by: Timur Tabi <timur@codeaurora.org>

This seems legit.  The comment for of_find_device_by_node() that says 
the np needs to be released was added after the code was written, so 
it's possible that I didn't know at the time that this was a requirement.

However, I no longer have the ability to test EMAC on device tree 
platforms, so I can't verify this code.
David Miller June 15, 2018, 12:01 a.m. | #3
From: YueHaibing <yuehaibing@huawei.com>
Date: Mon, 11 Jun 2018 21:03:45 +0800

> Add missing of_node_put() call for device node returned by
> of_parse_phandle().
> 
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Applied, thank you.

Patch

diff --git a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
index e78e5db..c694e34 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
@@ -384,6 +384,7 @@  int emac_sgmii_config(struct platform_device *pdev, struct emac_adapter *adpt)
 		}
 
 		sgmii_pdev = of_find_device_by_node(np);
+		of_node_put(np);
 		if (!sgmii_pdev) {
 			dev_err(&pdev->dev, "invalid internal-phy property\n");
 			return -ENODEV;