Skip to content

Commit 9de4211

Browse files
Xiu Jianfenggregkh
authored andcommitted
clk: socfpga: Fix memory leak in socfpga_gate_init()
[ Upstream commit 0b8ba89 ] Free @socfpga_clk and @ops on the error path to avoid memory leak issue. Fixes: a30a67b ("clk: socfpga: Don't have get_parent for single parent ops") Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> Link: https://lore.kernel.org/r/20221123031622.63171-1-xiujianfeng@huawei.com Acked-by: Dinh Nguyen <dinguyen@kernel.org> Signed-off-by: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e515881 commit 9de4211

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/clk/socfpga/clk-gate.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,10 @@ void __init socfpga_gate_init(struct device_node *node)
188188
return;
189189

190190
ops = kmemdup(&gateclk_ops, sizeof(gateclk_ops), GFP_KERNEL);
191-
if (WARN_ON(!ops))
191+
if (WARN_ON(!ops)) {
192+
kfree(socfpga_clk);
192193
return;
194+
}
193195

194196
rc = of_property_read_u32_array(node, "clk-gate", clk_gate, 2);
195197
if (rc)
@@ -243,6 +245,7 @@ void __init socfpga_gate_init(struct device_node *node)
243245

244246
err = clk_hw_register(NULL, hw_clk);
245247
if (err) {
248+
kfree(ops);
246249
kfree(socfpga_clk);
247250
return;
248251
}

0 commit comments

Comments
 (0)