soc: bcm: brcmstb: Don't leak device tree node reference
PATCH v2 1/1 soc: bcm: brcmstb: Don't leak device tree node reference
of_find_node_by_path() acquires a reference to the node returned by it and that reference needs to be dropped by its caller. soc_is_brcmstb() doesn't do that, so fix it.
[treding: slightly rewrite to avoid inline comparison]
---
Changes in v2:
-update changelog
-slightly rewrite to avoid inline comparison
--- drivers/soc/bcm/brcmstb/common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/soc/bcm/brcmstb/common.c +5 -1
@@ -31,13 +31,17 @@ static const struct of_device_id brcmstb_machine_match[] = {bool soc_is_brcmstb (void ) { +const struct of_device_id *match;struct device_node *root; root =of_find_node_by_path ("/" );if (!root)return false; -return of_match_node (brcmstb_machine_match, root) !=NULL ; + match =of_match_node (brcmstb_machine_match, root); +of_node_put (root); + +return match !=NULL ; }u32 brcmstb_get_family_id (void )
Signature · 1 line
2.17.0
Quoted 40 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.soc_is_brcmstb()doesn't do that, so fix it.[treding: slightly rewrite to avoid inline comparison]
Signed-off-by Yangtao Li <[email protected]>---
Changes in v2:(quoted diff) +0
-3-update changelog -slightly rewrite to avoid inline comparison --- drivers/soc/bcm/brcmstb/common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/soc/bcm/brcmstb/common.c +5
-2@@ -31,13 +31,17 @@ static const struct of_device_id brcmstb_machine_match[] = {bool soc_is_brcmstb (void ) { +const struct of_device_id *match;struct device_node *root; root =of_find_node_by_path ("/" );if (!root)return false; -return of_match_node (brcmstb_machine_match, root) !=NULL ; + match =of_match_node (brcmstb_machine_match, root); +of_node_put (root); + +return match !=NULL ; }u32 brcmstb_get_family_id (void ) --
Quoted 2 lines
2.17.0
Hi Florian:
How about this ?
MBR,
Yangtao
Quoted 39 lines · Frank Lee
Quoted 38 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.soc_is_brcmstb()doesn't do that, so fix it.[treding: slightly rewrite to avoid inline comparison]
Signed-off-by Yangtao Li <[email protected]>---
Changes in v2:(quoted diff) +0
-3-update changelog -slightly rewrite to avoid inline comparison --- drivers/soc/bcm/brcmstb/common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/soc/bcm/brcmstb/common.c +5
-1@@ -31,13 +31,17 @@ static const struct of_device_id brcmstb_machine_match[] = {bool soc_is_brcmstb (void ) { +const struct of_device_id *match;struct device_node *root; root =of_find_node_by_path ("/" );if (!root)return false; -return of_match_node (brcmstb_machine_match, root) !=NULL ; + match =of_match_node (brcmstb_machine_match, root); +of_node_put (root); + +return match !=NULL ; }
Quoted 7 lines
Quoted 4 lines
drivers/soc/bcm/brcmstb/common.c +0
-1u32 brcmstb_get_family_id (void ) --2.17.0
Hi Florian:
How about this ?
This looks better, I will add:
while applying the patch.
Signature · 1 line
Florian
Florian Fainelli
AppliedQuoted 7 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.soc_is_brcmstb()doesn't do that, so fix it.[treding: slightly rewrite to avoid inline comparison]
Signed-off-by Yangtao Li <[email protected]>
Applied to drivers/next, thanks!
Signature · 1 line
Florian