Skip to content

Commit bd54ccc

Browse files
Dan Carpenterbebarino
authored andcommitted
clk: mediatek: fix double free in mtk_clk_register_pllfh()
The mtk_clk_register_pll_ops() currently frees the "pll" parameter. The function has two callers, mtk_clk_register_pll() and mtk_clk_register_pllfh(). The first one, the _pll() function relies on the free, but for the second _pllfh() function it causes a double free bug. Really the frees should be done in the caller because that's where the allocation is. Fixes: d7964de ("clk: mediatek: Add new clock driver to handle FHCTL hardware") Signed-off-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 0d6e24b commit bd54ccc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/clk/mediatek/clk-pll.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,8 @@ struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll,
321321

322322
ret = clk_hw_register(NULL, &pll->hw);
323323

324-
if (ret) {
325-
kfree(pll);
324+
if (ret)
326325
return ERR_PTR(ret);
327-
}
328326

329327
return &pll->hw;
330328
}
@@ -340,6 +338,8 @@ struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data,
340338
return ERR_PTR(-ENOMEM);
341339

342340
hw = mtk_clk_register_pll_ops(pll, data, base, &mtk_pll_ops);
341+
if (IS_ERR(hw))
342+
kfree(pll);
343343

344344
return hw;
345345
}

0 commit comments

Comments
 (0)