Skip to content

Commit fed6bf5

Browse files
elfringabelvesa
authored andcommitted
clk: imx: composite-8m: Less function calls in __imx8m_clk_hw_composite() after error detection
The function “kfree” was called in up to three cases by the function “__imx8m_clk_hw_composite” during error handling even if the passed variables contained a null pointer. Adjust jump targets according to the Linux coding style convention. Signed-off-by: Markus Elfring <[email protected]> Reviewed-by: Peng Fan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Abel Vesa <[email protected]>
1 parent 6613476 commit fed6bf5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/clk/imx/clk-composite-8m.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
220220

221221
mux = kzalloc(sizeof(*mux), GFP_KERNEL);
222222
if (!mux)
223-
goto fail;
223+
return ERR_CAST(hw);
224224

225225
mux_hw = &mux->hw;
226226
mux->reg = reg;
@@ -230,7 +230,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
230230

231231
div = kzalloc(sizeof(*div), GFP_KERNEL);
232232
if (!div)
233-
goto fail;
233+
goto free_mux;
234234

235235
div_hw = &div->hw;
236236
div->reg = reg;
@@ -260,7 +260,7 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
260260
if (!mcore_booted) {
261261
gate = kzalloc(sizeof(*gate), GFP_KERNEL);
262262
if (!gate)
263-
goto fail;
263+
goto free_div;
264264

265265
gate_hw = &gate->hw;
266266
gate->reg = reg;
@@ -272,13 +272,15 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
272272
mux_hw, mux_ops, div_hw,
273273
divider_ops, gate_hw, &clk_gate_ops, flags);
274274
if (IS_ERR(hw))
275-
goto fail;
275+
goto free_gate;
276276

277277
return hw;
278278

279-
fail:
279+
free_gate:
280280
kfree(gate);
281+
free_div:
281282
kfree(div);
283+
free_mux:
282284
kfree(mux);
283285
return ERR_CAST(hw);
284286
}

0 commit comments

Comments
 (0)