mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-09 04:21:03 -04:00
clk: renesas: rzg2l: Fix a double free on error
The "pll_clk" and "clock" pointers are allocated with devm_kzalloc() so
freeing them with kfree() will lead to a double free. This would only
happen if probe failed, and the system is not bootable.
Fixes: ef3c613ccd ("clk: renesas: Add CPG core wrapper for RZ/G2L SoC")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://lore.kernel.org/r/YMtYs7LVveYH4eRe@mwanda
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
This commit is contained in:
committed by
Geert Uytterhoeven
parent
97c2975559
commit
36aaa3a0d9
@@ -175,7 +175,6 @@ rzg2l_cpg_pll_clk_register(const struct cpg_core_clk *core,
|
||||
struct clk_init_data init;
|
||||
const char *parent_name;
|
||||
struct pll_clk *pll_clk;
|
||||
struct clk *clk;
|
||||
|
||||
parent = clks[core->parent & 0xffff];
|
||||
if (IS_ERR(parent))
|
||||
@@ -198,11 +197,7 @@ rzg2l_cpg_pll_clk_register(const struct cpg_core_clk *core,
|
||||
pll_clk->priv = priv;
|
||||
pll_clk->type = core->type;
|
||||
|
||||
clk = clk_register(NULL, &pll_clk->hw);
|
||||
if (IS_ERR(clk))
|
||||
kfree(pll_clk);
|
||||
|
||||
return clk;
|
||||
return clk_register(NULL, &pll_clk->hw);
|
||||
}
|
||||
|
||||
static struct clk
|
||||
@@ -471,7 +466,6 @@ rzg2l_cpg_register_mod_clk(const struct rzg2l_mod_clk *mod,
|
||||
fail:
|
||||
dev_err(dev, "Failed to register %s clock %s: %ld\n", "module",
|
||||
mod->name, PTR_ERR(clk));
|
||||
kfree(clock);
|
||||
}
|
||||
|
||||
#define rcdev_to_priv(x) container_of(x, struct rzg2l_cpg_priv, rcdev)
|
||||
|
||||
Reference in New Issue
Block a user