linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] soc: brcmstb: Do not leak OF node reference
@ 2018-01-12 13:38 Thierry Reding
  2018-01-12 13:38 ` [PATCH 2/3] soc: brcmstb: Do not fail initcalls on non-STB platforms Thierry Reding
  2018-01-12 13:38 ` [PATCH 3/3] soc: brcmstb: Avoid error messages " Thierry Reding
  0 siblings, 2 replies; 3+ messages in thread
From: Thierry Reding @ 2018-01-12 13:38 UTC (permalink / raw)
  To: linux-arm-kernel

From: Thierry Reding <treding@nvidia.com>

The reference to the OF node should be dropped when no longer needed.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/soc/bcm/brcmstb/common.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/soc/bcm/brcmstb/common.c b/drivers/soc/bcm/brcmstb/common.c
index 4fe1cb73b39a..816a0f55a9ea 100644
--- a/drivers/soc/bcm/brcmstb/common.c
+++ b/drivers/soc/bcm/brcmstb/common.c
@@ -70,19 +70,25 @@ static int __init brcmstb_soc_device_early_init(void)
 {
 	struct device_node *sun_top_ctrl;
 	void __iomem *sun_top_ctrl_base;
+	int err = 0;
 
 	sun_top_ctrl = of_find_matching_node(NULL, sun_top_ctrl_match);
 	if (!sun_top_ctrl)
 		return -ENODEV;
 
 	sun_top_ctrl_base = of_iomap(sun_top_ctrl, 0);
-	if (!sun_top_ctrl_base)
-		return -ENODEV;
+	if (!sun_top_ctrl_base) {
+		err = -ENODEV;
+		goto put_node;
+	}
 
 	family_id = readl(sun_top_ctrl_base);
 	product_id = readl(sun_top_ctrl_base + 0x4);
 	iounmap(sun_top_ctrl_base);
-	return 0;
+
+put_node:
+	of_node_put(sun_top_ctrl);
+	return err;
 }
 early_initcall(brcmstb_soc_device_early_init);
 
@@ -96,6 +102,8 @@ static int __init brcmstb_soc_device_init(void)
 	if (!sun_top_ctrl)
 		return -ENODEV;
 
+	of_node_put(sun_top_ctrl);
+
 	soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
 	if (!soc_dev_attr)
 		return -ENOMEM;
-- 
2.15.1

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

end of thread, other threads:[~2018-01-12 13:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-12 13:38 [PATCH 1/3] soc: brcmstb: Do not leak OF node reference Thierry Reding
2018-01-12 13:38 ` [PATCH 2/3] soc: brcmstb: Do not fail initcalls on non-STB platforms Thierry Reding
2018-01-12 13:38 ` [PATCH 3/3] soc: brcmstb: Avoid error messages " Thierry Reding

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