Commit d6f620a457aa4c5c2e8d1a079a1236216c445aba
Committed by
Jason Cooper
1 parent
11d5993df2
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
clk: mvebu/clk-cpu.c: fix memory leakage
the variable cpuclk and clk_name should be properly freed when error happens. Signed-off-by: Cong Ding <dinggnu@gmail.com> Acked-by: Jason Cooper <jason@lakedaemon.net> Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com> Acked-by: Mike Turquette <mturquette@linaro.org> Signed-off-by: Jason Cooper <jason@lakedaemon.net>
Showing 1 changed file with 6 additions and 3 deletions Side-by-side Diff
drivers/clk/mvebu/clk-cpu.c
... | ... | @@ -124,7 +124,7 @@ |
124 | 124 | |
125 | 125 | clks = kzalloc(ncpus * sizeof(*clks), GFP_KERNEL); |
126 | 126 | if (WARN_ON(!clks)) |
127 | - return; | |
127 | + goto clks_out; | |
128 | 128 | |
129 | 129 | for_each_node_by_type(dn, "cpu") { |
130 | 130 | struct clk_init_data init; |
131 | 131 | |
... | ... | @@ -134,11 +134,11 @@ |
134 | 134 | int cpu, err; |
135 | 135 | |
136 | 136 | if (WARN_ON(!clk_name)) |
137 | - return; | |
137 | + goto bail_out; | |
138 | 138 | |
139 | 139 | err = of_property_read_u32(dn, "reg", &cpu); |
140 | 140 | if (WARN_ON(err)) |
141 | - return; | |
141 | + goto bail_out; | |
142 | 142 | |
143 | 143 | sprintf(clk_name, "cpu%d", cpu); |
144 | 144 | parent_clk = of_clk_get(node, 0); |
... | ... | @@ -167,6 +167,9 @@ |
167 | 167 | return; |
168 | 168 | bail_out: |
169 | 169 | kfree(clks); |
170 | + while(ncpus--) | |
171 | + kfree(cpuclk[ncpus].clk_name); | |
172 | +clks_out: | |
170 | 173 | kfree(cpuclk); |
171 | 174 | } |
172 | 175 |