Skip to contentSkip to conversation

clk: socfpga: Fix a potential memory leak for kzalloc()

PATCH New QintaoShen 1 participant 1 message Mar 24, 2022

Subsystems (2)
lore
Share & tools
lore

QintaoShen

author
#0 lore raw

PATCH 1/1 clk: socfpga: Fix a potential memory leak for kzalloc()

kfree() is missing on an error path to free the memory allocated by kzalloc().

---
 drivers/clk/socfpga/clk-gate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/socfpga/clk-gate.c +3 -1
index 53d6e3e..0ca5e00 100644
@@ -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)
Signature · 1 line
2.7.4