[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEExFWt45G5hyAEZvaAW--ZANnTqmi7-i473jRfFLD0Wacp6-w@mail.gmail.com>
Date: Sat, 24 Nov 2018 22:58:40 +0800
From: Frank Lee <tiny.windzz@...il.com>
To: Daniel Lezcano <daniel.lezcano@...aro.org>, tglx@...utronix.de
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH] clocksource/drivers/integrator-ap: add missing of_node_put()
On Thu, Nov 22, 2018 at 11:23 PM Yangtao Li <tiny.windzz@...il.com> wrote:
>
> 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, so fix it.
>
> Signed-off-by: Yangtao Li <tiny.windzz@...il.com>
> ---
> drivers/clocksource/timer-integrator-ap.c | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/clocksource/timer-integrator-ap.c b/drivers/clocksource/timer-integrator-ap.c
> index 76e526f58620..1f04069470bb 100644
> --- a/drivers/clocksource/timer-integrator-ap.c
> +++ b/drivers/clocksource/timer-integrator-ap.c
> @@ -177,7 +177,7 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)
> {
> const char *path;
> void __iomem *base;
> - int err;
> + int err,rc = 0;
> int irq;
> struct clk *clk;
> unsigned long rate;
> @@ -210,26 +210,34 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)
> "arm,timer-secondary", &path);
> if (err) {
> pr_warn("Failed to read property\n");
> - return err;
> + rc = err;
> + goto out_put_pri_node;
> }
>
>
> sec_node = of_find_node_by_path(path);
>
> - if (node == pri_node)
> + if (node == pri_node){
> /* The primary timer lacks IRQ, use as clocksource */
> - return integrator_clocksource_init(rate, base);
> + rc = integrator_clocksource_init(rate, base);
> + goto out;
> + }
>
> if (node == sec_node) {
> /* The secondary timer will drive the clock event */
> irq = irq_of_parse_and_map(node, 0);
> - return integrator_clockevent_init(rate, base, irq);
> + rc = integrator_clockevent_init(rate, base, irq);
> + goto out;
> }
>
> pr_info("Timer @%p unused\n", base);
> clk_disable_unprepare(clk);
> +out:
> + of_node_put(sec_node);
> +out_put_pri_node:
> + of_node_put(pri_node);
>
> - return 0;
> + return rc;
> }
>
> TIMER_OF_DECLARE(integrator_ap_timer, "arm,integrator-timer",
> --
> 2.17.0
>
Hi Daniel:
How about this?
Thanks,
Yangtao
Powered by blists - more mailing lists