* [PATCH] clk: socfpga: Fix memory leak in socfpga_gate_init()
@ 2022-11-23 3:16 Xiu Jianfeng
2022-12-01 16:36 ` Dinh Nguyen
2022-12-09 1:16 ` Stephen Boyd
0 siblings, 2 replies; 3+ messages in thread
From: Xiu Jianfeng @ 2022-11-23 3:16 UTC (permalink / raw)
To: dinguyen, mturquette, sboyd; +Cc: linux-clk, linux-kernel
Free @socfpga_clk and @ops on the error path to avoid memory leak issue.
Fixes: a30a67be7b6e ("clk: socfpga: Don't have get_parent for single parent ops")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
drivers/clk/socfpga/clk-gate.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
index 3e347b9e9eff..0c18c55edf8c 100644
--- a/drivers/clk/socfpga/clk-gate.c
+++ b/drivers/clk/socfpga/clk-gate.c
@@ -133,8 +133,10 @@ void __init socfpga_gate_init(struct device_node *node)
return;
ops = kmemdup(&gateclk_ops, sizeof(gateclk_ops), GFP_KERNEL);
- if (WARN_ON(!ops))
+ if (WARN_ON(!ops)) {
+ kfree(socfpga_clk);
return;
+ }
rc = of_property_read_u32_array(node, "clk-gate", clk_gate, 2);
if (rc)
@@ -182,6 +184,7 @@ void __init socfpga_gate_init(struct device_node *node)
err = clk_hw_register(NULL, hw_clk);
if (err) {
+ kfree(ops);
kfree(socfpga_clk);
return;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] clk: socfpga: Fix memory leak in socfpga_gate_init()
2022-11-23 3:16 [PATCH] clk: socfpga: Fix memory leak in socfpga_gate_init() Xiu Jianfeng
@ 2022-12-01 16:36 ` Dinh Nguyen
2022-12-09 1:16 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Dinh Nguyen @ 2022-12-01 16:36 UTC (permalink / raw)
To: Xiu Jianfeng, mturquette, sboyd; +Cc: linux-clk, linux-kernel
On 11/22/22 21:16, Xiu Jianfeng wrote:
> Free @socfpga_clk and @ops on the error path to avoid memory leak issue.
>
> Fixes: a30a67be7b6e ("clk: socfpga: Don't have get_parent for single parent ops")
> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
> ---
> drivers/clk/socfpga/clk-gate.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
> index 3e347b9e9eff..0c18c55edf8c 100644
> --- a/drivers/clk/socfpga/clk-gate.c
> +++ b/drivers/clk/socfpga/clk-gate.c
> @@ -133,8 +133,10 @@ void __init socfpga_gate_init(struct device_node *node)
> return;
>
> ops = kmemdup(&gateclk_ops, sizeof(gateclk_ops), GFP_KERNEL);
> - if (WARN_ON(!ops))
> + if (WARN_ON(!ops)) {
> + kfree(socfpga_clk);
> return;
> + }
>
> rc = of_property_read_u32_array(node, "clk-gate", clk_gate, 2);
> if (rc)
> @@ -182,6 +184,7 @@ void __init socfpga_gate_init(struct device_node *node)
>
> err = clk_hw_register(NULL, hw_clk);
> if (err) {
> + kfree(ops);
> kfree(socfpga_clk);
> return;
> }
Acked-by: Dinh Nguyen <dinguyen@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] clk: socfpga: Fix memory leak in socfpga_gate_init()
2022-11-23 3:16 [PATCH] clk: socfpga: Fix memory leak in socfpga_gate_init() Xiu Jianfeng
2022-12-01 16:36 ` Dinh Nguyen
@ 2022-12-09 1:16 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2022-12-09 1:16 UTC (permalink / raw)
To: Xiu Jianfeng, dinguyen, mturquette; +Cc: linux-clk, linux-kernel
Quoting Xiu Jianfeng (2022-11-22 19:16:22)
> Free @socfpga_clk and @ops on the error path to avoid memory leak issue.
>
> Fixes: a30a67be7b6e ("clk: socfpga: Don't have get_parent for single parent ops")
> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
> ---
Applied to clk-next
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-09 1:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 3:16 [PATCH] clk: socfpga: Fix memory leak in socfpga_gate_init() Xiu Jianfeng
2022-12-01 16:36 ` Dinh Nguyen
2022-12-09 1:16 ` Stephen Boyd
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).