[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250726121014-GYA756241@gentoo>
Date: Sat, 26 Jul 2025 20:10:14 +0800
From: Yixun Lan <dlan@...too.org>
To: Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc: Hendrik Hamerlinck <hendrik.hamerlinck@...mernet.be>, sboyd@...nel.org,
skhan@...uxfoundation.org, linux-kernel-mentees@...ts.linux.dev,
linux-clk@...r.kernel.org, linux-riscv@...ts.infradead.org,
spacemit@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] clk: spacemit: fix resource leak in
spacemit_ccu_reset_register
Hi Christophe,
On 11:16 Sat 26 Jul , Christophe JAILLET wrote:
> Le 23/07/2025 à 15:25, Hendrik Hamerlinck a écrit :
> > The function spacemit_ccu_reset_register() allocates memory for an
> > auxiliary device. If auxiliary_device_add() fails, it skips cleanup of
> > these resources, resulting in leaks.
> >
> > Fix this by using the appropriate error handling path.
> >
> > Fixes: 988543522ebd ("clk: spacemit: set up reset auxiliary devices")
> > Signed-off-by: Hendrik Hamerlinck <hendrik.hamerlinck@...mernet.be>
> > Reviewed-by: Yixun Lan <dlan@...too.org>
> > ---
> > Changes in v2:
> > - Properly place the Fixes tip.
> > ---
> > drivers/clk/spacemit/ccu-k1.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/clk/spacemit/ccu-k1.c b/drivers/clk/spacemit/ccu-k1.c
> > index 65e6de030717..5bb85e32c6cf 100644
> > --- a/drivers/clk/spacemit/ccu-k1.c
> > +++ b/drivers/clk/spacemit/ccu-k1.c
> > @@ -1059,7 +1059,7 @@ static int spacemit_ccu_reset_register(struct device *dev,
> > ret = auxiliary_device_add(adev);
> > if (ret) {
> > auxiliary_device_uninit(adev);
> > - return ret;
> > + goto err_free_aux_id;
> > }
> >
> > return devm_add_action_or_reset(dev, spacemit_adev_unregister, adev);
>
>
> Hi,
>
> I'm not sure this is correct.
>
> auxiliary_device_uninit() which is called if auxiliary_device_add()
> fails should already do the clean-up.
>
thanks for your review,
auxiliary_device_uninit() call put_device() and will trigger release callback,
which then call spacemit_cadev_release() and do the ida_free()
> So I would say that this patch adds a double-free issue and should not
> be applied.
>
I agree
> If I'm right, note that Stephen has already added a "Applied to clk-next"
>
Stephen, can you drop this patch? or simply revert it if too late..
> CJ
>
>
--
Yixun Lan (dlan)
Powered by blists - more mailing lists