Skip to contentSkip to conversation

soc: bcm: brcmstb: add of_node_put()

PATCH In review Yangtao Li 2 participants 3 messages Nov 21, 2018 – Nov 22, 2018 Broadcom BCM7XXX Arm architecture

lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

PATCH 1/1 soc: bcm: brcmstb: add of_node_put()

of_find_node_by_path() acquires a reference to the node returned by it and that reference needs to be dropped by its caller. bl_idle_init() doesn't do that, so fix it.

---
 drivers/soc/bcm/brcmstb/common.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/soc/bcm/brcmstb/common.c +4 -1
index 14185451901d..95b777fffee6 100644
@@ -32,12 +32,15 @@ static const struct of_device_id brcmstb_machine_match[] = {
 bool soc_is_brcmstb(void)
 {
 	struct device_node *root;
+	bool rc;
 
 	root = of_find_node_by_path("/");
 	if (!root)
 		return false;
 
-	return of_match_node(brcmstb_machine_match, root) != NULL;
+	rc = of_match_node(brcmstb_machine_match, root) != NULL;
+	of_node_put(root);
+	return rc;
 }
 
 u32 brcmstb_get_family_id(void)
Signature · 1 line
2.17.0
#1 lore raw
Quoted 3 lines · Yangtao Li

of_find_node_by_path() acquires a reference to the node returned by it and that reference needs to be dropped by its caller. bl_idle_init() doesn't do that, so fix it.

You probably copied/pasted this from a prior patch, the function name is soc_is_brcmstb() here, do you mind fixing that and also providing a
Fixes: tag?

Thanks

Quoted 28 lines
---
 drivers/soc/bcm/brcmstb/common.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/soc/bcm/brcmstb/common.c +4 -1
index 14185451901d..95b777fffee6 100644
@@ -32,12 +32,15 @@ static const struct of_device_id brcmstb_machine_match[] = {
 bool soc_is_brcmstb(void)
 {
 	struct device_node *root;
+	bool rc;
 
 	root = of_find_node_by_path("/");
 	if (!root)
 		return false;
 
-	return of_match_node(brcmstb_machine_match, root) != NULL;
+	rc = of_match_node(brcmstb_machine_match, root) != NULL;
+	of_node_put(root);
+	return rc;
 }
 
 u32 brcmstb_get_family_id(void)
Signature · 1 line
Florian
author
#2 lore raw
Quoted 11 lines · Florian Fainelli
Quoted 3 lines · Yangtao Li

of_find_node_by_path() acquires a reference to the node returned by it and that reference needs to be dropped by its caller. bl_idle_init() doesn't do that, so fix it.

You probably copied/pasted this from a prior patch, the function name is soc_is_brcmstb() here, do you mind fixing that and also providing a
Fixes: tag?

Hi Florian:

Do you need me to send a patch that changed the commit log or refactor the soc_is_brcmstb()?
For example:
https://lore.kernel.org/patchwork/patch/1015523/

Yours,
Yangtao

Quoted 34 lines

Thanks

Quoted 18 lines
---
 drivers/soc/bcm/brcmstb/common.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/soc/bcm/brcmstb/common.c +1 -0
index 14185451901d..95b777fffee6 100644
@@ -32,12 +32,15 @@ static const struct of_device_id brcmstb_machine_match[] = {
 bool soc_is_brcmstb(void)
 {
      struct device_node *root;
+     bool rc;
 
      root = of_find_node_by_path("/");

drivers/soc/bcm/brcmstb/common.c static const struct of_device_id brcmstb_machine_match[] = { · line 46

Quoted 10 lines
drivers/soc/bcm/brcmstb/common.c +3 -1
      if (!root)
              return false;
 
-     return of_match_node(brcmstb_machine_match, root) != NULL;
+     rc = of_match_node(brcmstb_machine_match, root) != NULL;
+     of_node_put(root);
+     return rc;
 }
 
 u32 brcmstb_get_family_id(void)

--
Florian