clocksource/drivers/integrator-ap: add missing of_node_put()
PATCH v2 1/1 clocksource/drivers/integrator-ap: add missing 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. integrator_ap_timer_init_of() doesn't do that.The pri_node and the sec_node are used as an identifier to compare against the current node, we can directly drop the refcount after getting the node from path as it is not used aspointer. In addition, a single variable is needed, so fix it.
---
Changes in v2:
-update changeelog
-simplify fix
-change two variable to one
--- drivers/clocksource/timer-integrator-ap.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
drivers/clocksource/timer-integrator-ap.c +13 -9
@@ -181,8 +181,7 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)int irq;struct clk *clk;unsigned long rate; -struct device_node *pri_node; -struct device_node *sec_node; +struct device_node *alias_node; base =of_io_request_and_map (node,0 ,"integrator-timer" );if (IS_ERR (base))
@@ -204,7 +203,14 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)return err; } - pri_node =of_find_node_by_path (path); + alias_node =of_find_node_by_path (path); + +/* Drop the refcount of node */ +of_node_put (alias_node); + +if (node == alias_node) +/* The primary timer lacks IRQ, use as clocksource */ +return integrator_clocksource_init (rate, base); err =of_property_read_string (of_aliases,"arm,timer-secondary" , &path);
@@ -213,14 +219,12 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)return err; } + alias_node =of_find_node_by_path (path); - sec_node =of_find_node_by_path (path); - -if (node == pri_node) -/* The primary timer lacks IRQ, use as clocksource */ -return integrator_clocksource_init (rate, base); +/* Drop the refcount of node */ +of_node_put (alias_node); -if (node == sec_node) { +if (node == alias_node) {/* The secondary timer will drive the clock event */ irq =irq_of_parse_and_map (node,0 );return integrator_clockevent_init (rate, base, irq);
Signature · 1 line
2.17.0
Quoted 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.integrator_ap_timer_init_of()doesn't do that.Thepri_nodeand thesec_nodeare used as an identifier to compare against the current node, we can directly drop the refcount after getting the node from path as it is not used aspointer. In addition, a single variable is needed, so fix it.
I can apply the patch after adding a comment in the code below or alternatively you can resend a V3 after adding a comment yourself.
What is your preference?
Quoted 60 lines
Signed-off-by Yangtao Li <[email protected]>---
Changes in v2:(quoted diff) +0
-4-update changeelog -simplify fix -change two variable to one --- drivers/clocksource/timer-integrator-ap.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)drivers/clocksource/timer-integrator-ap.c +13
-9@@ -181,8 +181,7 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)int irq;struct clk *clk;unsigned long rate; -struct device_node *pri_node; -struct device_node *sec_node; +struct device_node *alias_node; base =of_io_request_and_map (node,0 ,"integrator-timer" );if (IS_ERR (base))@@ -204,7 +203,14 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)return err; } - pri_node =of_find_node_by_path (path); + alias_node =of_find_node_by_path (path); + +/* Drop the refcount of node */ +of_node_put (alias_node); + +if (node == alias_node) +/* The primary timer lacks IRQ, use as clocksource */ +return integrator_clocksource_init (rate, base); err =of_property_read_string (of_aliases,"arm,timer-secondary" , &path);@@ -213,14 +219,12 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)return err; } + alias_node =of_find_node_by_path (path); - sec_node =of_find_node_by_path (path); - -if (node == pri_node) -/* The primary timer lacks IRQ, use as clocksource */ -return integrator_clocksource_init (rate, base); +/* Drop the refcount of node */ +of_node_put (alias_node); -if (node == sec_node) { +if (node == alias_node) {/* The secondary timer will drive the clock event */ irq =irq_of_parse_and_map (node,0 );return integrator_clockevent_init (rate, base, irq);
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 10 lines · Daniel Lezcano
Quoted 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.integrator_ap_timer_init_of()doesn't do that.Thepri_nodeand thesec_nodeare used as an identifier to compare against the current node, we can directly drop the refcount after getting the node from path as it is not used aspointer. In addition, a single variable is needed, so fix it.
Quoted 4 lines
I can apply the patch after adding a comment in the code below or alternatively you can resend a V3 after adding a comment yourself.
What is your preference?
Hi Daniel:
You can add a comment in the code below,then apply the patch.
Thanks,
Yangtao
Quoted 70 lines
Quoted 51 lines
Signed-off-by Yangtao Li <[email protected]>---
Changes in v2:(quoted diff) +0
-4-update changeelog -simplify fix -change two variable to one --- drivers/clocksource/timer-integrator-ap.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)drivers/clocksource/timer-integrator-ap.c +10
-6@@ -181,8 +181,7 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)int irq;struct clk *clk;unsigned long rate; -struct device_node *pri_node; -struct device_node *sec_node; +struct device_node *alias_node; base =of_io_request_and_map (node,0 ,"integrator-timer" );if (IS_ERR (base))@@ -204,7 +203,14 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)return err; } - pri_node =of_find_node_by_path (path); + alias_node =of_find_node_by_path (path); + +/* Drop the refcount of node */ +of_node_put (alias_node); + +if (node == alias_node) +/* The primary timer lacks IRQ, use as clocksource */ +return integrator_clocksource_init (rate, base); err =of_property_read_string (of_aliases,"arm,timer-secondary" , &path);@@ -213,14 +219,12 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)return err; } + alias_node =of_find_node_by_path (path); - sec_node =of_find_node_by_path (path); - -if (node == pri_node)drivers/clocksource/timer-integrator-ap.c static int __init integrator_ap_timer_init_of(struct device_node *node) · line 230
Quoted 10 lines
drivers/clocksource/timer-integrator-ap.c +3
-3-/* The primary timer lacks IRQ, use as clocksource */ -return integrator_clocksource_init (rate, base); +/* Drop the refcount of node */ +of_node_put (alias_node); -if (node == sec_node) { +if (node == alias_node) {/* The secondary timer will drive the clock event */ irq =irq_of_parse_and_map (node,0 );return integrator_clockevent_init (rate, base, irq);--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCsFollow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog