Commit 0b8ba891 authored by Xiu Jianfeng's avatar Xiu Jianfeng Committed by Stephen Boyd

clk: socfpga: Fix memory leak in socfpga_gate_init()

Free @socfpga_clk and @ops on the error path to avoid memory leak issue.

Fixes: a30a67be ("clk: socfpga: Don't have get_parent for single parent ops")
Signed-off-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
Link: https://lore.kernel.org/r/20221123031622.63171-1-xiujianfeng@huawei.comAcked-by: default avatarDinh Nguyen <dinguyen@kernel.org>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent cfd3ffb3
......@@ -188,8 +188,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)
......@@ -243,6 +245,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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment