mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-30 06:10:56 +00:00
clk: mediatek: fix double free in mtk_clk_register_pllfh()
[ Upstream commitbd54ccc0f1
] 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:d7964de8a8
("clk: mediatek: Add new clock driver to handle FHCTL hardware") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://lore.kernel.org/r/cd7fa365-28cc-4c34-ac64-6da57c98baa6@moroto.mountain Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
ed02ca7ff3
commit
5a938500cd
1 changed files with 3 additions and 3 deletions
|
@ -321,10 +321,8 @@ struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll,
|
|||
|
||||
ret = clk_hw_register(NULL, &pll->hw);
|
||||
|
||||
if (ret) {
|
||||
kfree(pll);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
return &pll->hw;
|
||||
}
|
||||
|
@ -340,6 +338,8 @@ struct clk_hw *mtk_clk_register_pll(const struct mtk_pll_data *data,
|
|||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
hw = mtk_clk_register_pll_ops(pll, data, base, &mtk_pll_ops);
|
||||
if (IS_ERR(hw))
|
||||
kfree(pll);
|
||||
|
||||
return hw;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue