clk: versatile: Add of_node_put() before return statement
Subsystems (2)
PATCH 1/1 clk: versatile: Add of_node_put() before return statement
Every iteration of for_each_available_child_of_node() decrements the reference count of the previous node, however when control is transferred from the middle of the loop, as in the case of a return or break or goto, there is no decrement thus ultimately resulting in a memory leak.
Fix a potential memory leak in clk-impd1.c by inserting of_node_put() before a return statement.
Issue found with Coccinelle.
--- drivers/clk/versatile/clk-impd1.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/versatile/clk-impd1.c +3 -1
@@ -109,8 +109,10 @@ static int integrator_impd1_clk_probe(struct platform_device *pdev)for_each_available_child_of_node (np, child) { ret =integrator_impd1_clk_spawn (dev, np, child); -if (ret) +if (ret) { +of_node_put (child);break ; + } }return ret;
Signature · 1 line
2.17.1
Quoted 6 lines · Sumera Priyadarsini
Every iteration of
for_each_available_child_of_node()decrements the reference count of the previous node, however when control is transferred from the middle of the loop, as in the case of a return or break or goto, there is no decrement thus ultimately resulting in a memory leak.
Quoted 6 lines
Fix a potential memory leak in
clk-impd1.cby insertingof_node_put()before a return statement.Issue found with Coccinelle.
Signed-off-by Sumera Priyadarsini <[email protected]>
Yours,
Linus Walleij
Quoting Sumera Priyadarsini (2020-08-29 10:57:04)
Quoted 6 lines
Every iteration of
for_each_available_child_of_node()decrements the reference count of the previous node, however when control is transferred from the middle of the loop, as in the case of a return or break or goto, there is no decrement thus ultimately resulting in a memory leak.
Quoted 7 lines
Fix a potential memory leak in
clk-impd1.cby insertingof_node_put()before a return statement.Issue found with Coccinelle.
Signed-off-by Sumera Priyadarsini <[email protected]>---
Applied to clk-fixes