[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210106130745.GA8113@duo.ucw.cz>
Date: Wed, 6 Jan 2021 14:07:45 +0100
From: Pavel Machek <pavel@...x.de>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Dinghao Liu <dinghao.liu@....edu.cn>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Sasha Levin <sashal@...nel.org>
Subject: Re: [PATCH 5.4 34/47] rtc: sun6i: Fix memleak in sun6i_rtc_clk_init
Hi!
> From: Dinghao Liu <dinghao.liu@....edu.cn>
>
> [ Upstream commit 28d211919e422f58c1e6c900e5810eee4f1ce4c8 ]
>
> When clk_hw_register_fixed_rate_with_accuracy() fails,
> clk_data should be freed. It's the same for the subsequent
> two error paths, but we should also unregister the already
> registered clocks in them.
This still leaks rtc, AFAICT. What is worse, sun6i_rtc will point to
invalid memory after the error exit.
Something like this?
Best regards,
Pavel
diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
index e85abe805606..59389bb99e39 100644
--- a/drivers/rtc/rtc-sun6i.c
+++ b/drivers/rtc/rtc-sun6i.c
@@ -211,6 +211,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node)
rtc->base = of_io_request_and_map(node, 0, of_node_full_name(node));
if (IS_ERR(rtc->base)) {
pr_crit("Can't map RTC registers");
+ kfree(rtc);
goto err;
}
@@ -272,6 +273,8 @@ static void __init sun6i_rtc_clk_init(struct device_node *node)
clk_hw_unregister_fixed_rate(rtc->int_osc);
err:
kfree(clk_data);
+ kfree(rtc);
+ sun6i_rtc = NULL;
}
CLK_OF_DECLARE_DRIVER(sun6i_rtc_clk, "allwinner,sun6i-a31-rtc",
sun6i_rtc_clk_init);
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists