clk: socfpga: Fix memory leak in socfpga_gate_init()
Subsystems (2)
PATCH 1/1 clk: socfpga: Fix memory leak in socfpga_gate_init()
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 <[email protected]>
--- drivers/clk/socfpga/clk-gate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clk/socfpga/clk-gate.c +4 -1
@@ -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 ; }
Signature · 1 line
2.17.1
Quoted 25 lines · Xiu Jianfeng
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 <[email protected]>--- drivers/clk/socfpga/clk-gate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/clk/socfpga/clk-gate.c +3
-1@@ -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)
drivers/clk/socfpga/clk-gate.c void __init socfpga_gate_init(struct device_node *node) · line 190
Quoted 7 lines
drivers/clk/socfpga/clk-gate.c +1
-0@@ -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 <[email protected]>
Quoting Xiu Jianfeng (2022-11-22 19:16:22)
Quoted 5 lines
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 <[email protected]>---
Applied to clk-next