* [PATCH] rtc: sun6i: fix memory leak
@ 2017-09-17 12:43 Sudip Mukherjee
2017-09-27 13:25 ` Alexandre Belloni
0 siblings, 1 reply; 2+ messages in thread
From: Sudip Mukherjee @ 2017-09-17 12:43 UTC (permalink / raw)
To: linux-arm-kernel
If 'clk_data' is not allocated we returned but we failed to free 'rtc'.
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
drivers/rtc/rtc-sun6i.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
index 3d2216c..5bc28ee 100644
--- a/drivers/rtc/rtc-sun6i.c
+++ b/drivers/rtc/rtc-sun6i.c
@@ -201,8 +201,10 @@ static void __init sun6i_rtc_clk_init(struct device_node *node)
clk_data = kzalloc(sizeof(*clk_data) + (sizeof(*clk_data->hws) * 2),
GFP_KERNEL);
- if (!clk_data)
+ if (!clk_data) {
+ kfree(rtc);
return;
+ }
spin_lock_init(&rtc->lock);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] rtc: sun6i: fix memory leak
2017-09-17 12:43 [PATCH] rtc: sun6i: fix memory leak Sudip Mukherjee
@ 2017-09-27 13:25 ` Alexandre Belloni
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2017-09-27 13:25 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
On 17/09/2017 at 13:43:10 +0100, Sudip Mukherjee wrote:
> If 'clk_data' is not allocated we returned but we failed to free 'rtc'.
>
> Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> ---
> drivers/rtc/rtc-sun6i.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
> index 3d2216c..5bc28ee 100644
> --- a/drivers/rtc/rtc-sun6i.c
> +++ b/drivers/rtc/rtc-sun6i.c
> @@ -201,8 +201,10 @@ static void __init sun6i_rtc_clk_init(struct device_node *node)
>
> clk_data = kzalloc(sizeof(*clk_data) + (sizeof(*clk_data->hws) * 2),
> GFP_KERNEL);
> - if (!clk_data)
> + if (!clk_data) {
> + kfree(rtc);
> return;
> + }
Please also fix the other occurrence of the issue in the same function.
>
> spin_lock_init(&rtc->lock);
>
> --
> 2.7.4
>
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-27 13:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-17 12:43 [PATCH] rtc: sun6i: fix memory leak Sudip Mukherjee
2017-09-27 13:25 ` Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).