Hi Dan, Thank you for the fix. > -----Original Message----- > From: Dan Carpenter <dan.carpenter@xxxxxxxxxx> > Sent: 17 June 2021 15:14 > To: Geert Uytterhoeven <geert+renesas@xxxxxxxxx> > Cc: Michael Turquette <mturquette@xxxxxxxxxxxx>; Stephen Boyd <sboyd@xxxxxxxxxx>; Prabhakar Mahadev > Lad <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx>; Biju Das <biju.das.jz@xxxxxxxxxxxxxx>; linux-renesas- > soc@xxxxxxxxxxxxxxx; linux-clk@xxxxxxxxxxxxxxx; kernel-janitors@xxxxxxxxxxxxxxx > Subject: [PATCH v2 1/2] clk: renesas: 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: ef3c613ccd68 ("clk: renesas: Add CPG core wrapper for RZ/G2L SoC") > Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> > --- > V2: Fix "pll_clk" as well. > > drivers/clk/renesas/renesas-rzg2l-cpg.c | 7 +------ > 1 file changed, 1 insertion(+), 6 deletions(-) > Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx> Also Reported-by tag, Reported-by: kernel test robot <lkp@xxxxxxxxx> Cheers, Prabhakar > diff --git a/drivers/clk/renesas/renesas-rzg2l-cpg.c b/drivers/clk/renesas/renesas-rzg2l-cpg.c > index 5009b9e48b13..7ba36f19896f 100644 > --- a/drivers/clk/renesas/renesas-rzg2l-cpg.c > +++ b/drivers/clk/renesas/renesas-rzg2l-cpg.c > @@ -199,11 +199,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 > @@ -473,7 +469,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) > -- > 2.30.2