* [PATCH] MIPS: Alchemy: Fix memleak in alchemy_clk_setup_cpu
@ 2020-11-13 13:18 Zhang Qilong
2020-11-17 12:00 ` Thomas Bogendoerfer
0 siblings, 1 reply; 2+ messages in thread
From: Zhang Qilong @ 2020-11-13 13:18 UTC (permalink / raw)
To: tsbogend; +Cc: linux-mips
If the clk_register fails, we should free h before
function returns to prevent memleak.
Fixes: 474402291a0ad ("MIPS: Alchemy: clock framework integration of onchip clocks")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
arch/mips/alchemy/common/clock.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/mips/alchemy/common/clock.c b/arch/mips/alchemy/common/clock.c
index a95a894aceaf..f0c830337104 100644
--- a/arch/mips/alchemy/common/clock.c
+++ b/arch/mips/alchemy/common/clock.c
@@ -152,6 +152,7 @@ static struct clk __init *alchemy_clk_setup_cpu(const char *parent_name,
{
struct clk_init_data id;
struct clk_hw *h;
+ struct clk *clk;
h = kzalloc(sizeof(*h), GFP_KERNEL);
if (!h)
@@ -164,7 +165,13 @@ static struct clk __init *alchemy_clk_setup_cpu(const char *parent_name,
id.ops = &alchemy_clkops_cpu;
h->init = &id;
- return clk_register(NULL, h);
+ clk = clk_register(NULL, h);
+ if (IS_ERR(clk)) {
+ pr_err("failed to register clock\n");
+ kfree(h);
+ }
+
+ return clk;
}
/* AUXPLLs ************************************************************/
--
2.25.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] MIPS: Alchemy: Fix memleak in alchemy_clk_setup_cpu
2020-11-13 13:18 [PATCH] MIPS: Alchemy: Fix memleak in alchemy_clk_setup_cpu Zhang Qilong
@ 2020-11-17 12:00 ` Thomas Bogendoerfer
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Bogendoerfer @ 2020-11-17 12:00 UTC (permalink / raw)
To: Zhang Qilong; +Cc: linux-mips
On Fri, Nov 13, 2020 at 09:18:56PM +0800, Zhang Qilong wrote:
> If the clk_register fails, we should free h before
> function returns to prevent memleak.
>
> Fixes: 474402291a0ad ("MIPS: Alchemy: clock framework integration of onchip clocks")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
> ---
> arch/mips/alchemy/common/clock.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
applied to mips-fixes.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-17 12:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-13 13:18 [PATCH] MIPS: Alchemy: Fix memleak in alchemy_clk_setup_cpu Zhang Qilong
2020-11-17 12:00 ` Thomas Bogendoerfer
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.