Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: rockchip: free memory in error cases when registering clock branches

Add free memeory if rockchip_clk_register_branch fails.

Fixes: a245fecbb806 ("clk: rockchip: add basic infrastructure...")
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>

authored by

Shawn Lin and committed by
Heiko Stuebner
2467b674 89aa027e

+7 -2
+7 -2
drivers/clk/rockchip/clk.c
··· 70 70 if (gate_offset >= 0) { 71 71 gate = kzalloc(sizeof(*gate), GFP_KERNEL); 72 72 if (!gate) 73 - return ERR_PTR(-ENOMEM); 73 + goto err_gate; 74 74 75 75 gate->flags = gate_flags; 76 76 gate->reg = base + gate_offset; ··· 82 82 if (div_width > 0) { 83 83 div = kzalloc(sizeof(*div), GFP_KERNEL); 84 84 if (!div) 85 - return ERR_PTR(-ENOMEM); 85 + goto err_div; 86 86 87 87 div->flags = div_flags; 88 88 div->reg = base + muxdiv_offset; ··· 100 100 flags); 101 101 102 102 return clk; 103 + err_div: 104 + kfree(gate); 105 + err_gate: 106 + kfree(mux); 107 + return ERR_PTR(-ENOMEM); 103 108 } 104 109 105 110 struct rockchip_clk_frac {