Driver: clk-qoriq.c: replace of_node_put with _free improves cleanup
PATCH 1/1 Driver: clk-qoriq.c: replace of_node_put with _free improves cleanup
Use the _free function to have automatic clean up instead of calling another function, of_node_put. This prevents leaking reference counts.
The following commit has information on _free(device_node):
9448e55d032d99af8e23487f51a542d51b2f1a48
The code was able to compile without errors or warnings.
--- drivers/clk/clk-qoriq.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/clk/clk-qoriq.c +1 -4
@@ -1065,11 +1065,8 @@ static void __init _clockgen_init(struct device_node *np, bool legacy);static void __init legacy_init_clockgen (struct device_node *np) {if (!clockgen.node) { -struct device_node *parent_np; - - parent_np =of_get_parent (np); + struct device_node __free(device_node) *parent_np = of_get_parent(np);_clockgen_init (parent_np, true); -of_node_put (parent_np); } }
Signature · 1 line
2.43.0
Stephen Boyd
maintainerQuoting David Hunter (2024-08-19 18:35:49)
Quoted 1 line
Use the
_freefunction to have automatic clean up instead of calling
How about:
Use __free() to have automatic cleanup instead of calling of_node_put() manually.
Quoted 1 line
another function,
of_node_put. This prevents leaking reference counts.
Are there any leaking reference counts? I'd just omit that sentence unless there is one.
Quoted 6 lines
The following commit has information on
_free(device_node):
9448e55d032d99af8e23487f51a542d51b2f1a48The code was able to compile without errors or warnings.
The rest of this can go below the triple dash ---
PATCH v2 1/1 Driver: clk-qoriq.c: replace of_node_put with _free improves cleanup
Use _free() to have automatic cleanup instead of calling of_node_put() manually.
Compiled without errors or warnings.
---
The following commit has information on _free(device_node):9448e55d032d99af8e23487f51a542d51b2f1a48
V1 --> V2
- Improved message body
- Use change log to give more information about _free()
--- drivers/clk/clk-qoriq.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/clk/clk-qoriq.c +1 -4
@@ -1065,11 +1065,8 @@ static void __init _clockgen_init(struct device_node *np, bool legacy);static void __init legacy_init_clockgen (struct device_node *np) {if (!clockgen.node) { -struct device_node *parent_np; - - parent_np =of_get_parent (np); + struct device_node __free(device_node) *parent_np = of_get_parent(np);_clockgen_init (parent_np, true); -of_node_put (parent_np); } }
Signature · 1 line
2.43.0
Stephen Boyd
maintainerThe subject should be
clk: clk-qoriq: Replace of_node_put() with __free()
Quoting David Hunter (2024-08-20 18:07:39)
Quoted 1 line
Use
_free()to have automatic cleanup instead of callingof_node_put()
__free()
Quoted 4 lines
manually.
Compiled without errors or warnings.
Quoted 8 lines
Signed-off-by David Hunter <[email protected]>---
The following commit has information on_free(device_node):9448e55d032d99af8e23487f51a542d51b2f1a48V1 --> V2
- Improved message body
- Use change log to give more information about_free()
Please don't send the next version as a reply to the previous patch.
Quoted 9 lines
--- drivers/clk/clk-qoriq.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/clk/clk-qoriq.c +0
-0
drivers/clk/clk-qoriq.c static void __init _clockgen_init(struct device_node *np, bool legacy); · line 1068
Quoted 7 lines
drivers/clk/clk-qoriq.c +1
-3@@ -1065,11 +1065,8 @@ static void __init _clockgen_init(struct device_node *np, bool legacy);static void __init legacy_init_clockgen (struct device_node *np) {if (!clockgen.node) { -struct device_node *parent_np; - - parent_np =of_get_parent (np); + struct device_node __free(device_node) *parent_np = of_get_parent(np);
It seems the __free() comes after the variable name declaration if my grep skills are working today.
Also, please include linux/cleanup.h at the top of the file for __free().
Quoted 4 lines
drivers/clk/clk-qoriq.c +0
-1_clockgen_init (parent_np, true); -of_node_put (parent_np); } }