From: Hendrik Hamerlinck <hendrik.hamerlinck@hammernet.be>
To: Alex Elder <elder@ieee.org>,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
sboyd@kernel.org, dlan@gentoo.org
Cc: skhan@linuxfoundation.org, linux-kernel-mentees@lists.linux.dev,
linux-clk@vger.kernel.org, linux-riscv@lists.infradead.org,
spacemit@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] clk: spacemit: fix resource leak in spacemit_ccu_reset_register
Date: Sat, 26 Jul 2025 20:00:10 +0200 [thread overview]
Message-ID: <a9acf284-d55c-4c8e-9f34-c2feb26a446b@hammernet.be> (raw)
In-Reply-To: <d968eb77-50f2-4d28-a57a-112c87dff8bf@ieee.org>
On 7/26/25 14:57, Alex Elder wrote:
> On 7/26/25 4:16 AM, 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@hammernet.be>
>>> Reviewed-by: Yixun Lan <dlan@gentoo.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.
>
> I'm sure this patch is incorrect, and the original code did
> not have the stated problem. Thank you for calling attention
> to this Christophe.
>
> Stephen, could you please revert your commit of this patch?
>
> Thank you.
>
> -Alex
>
My apologies, I am terribly sorry for this mistake. I was convinced that
this was a leak but was not thorough enough in checking it.
Thank you for catching this issue in time. I will make sure to be more
careful in the future. Sorry for your troubles on this.
Kind regards,
Hendrik
prev parent reply other threads:[~2025-07-26 18:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-23 13:25 [PATCH v2] clk: spacemit: fix resource leak in spacemit_ccu_reset_register Hendrik Hamerlinck
2025-07-25 2:36 ` Stephen Boyd
2025-07-26 9:16 ` Christophe JAILLET
2025-07-26 12:10 ` Yixun Lan
2025-07-26 12:57 ` Alex Elder
2025-07-26 18:00 ` Hendrik Hamerlinck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a9acf284-d55c-4c8e-9f34-c2feb26a446b@hammernet.be \
--to=hendrik.hamerlinck@hammernet.be \
--cc=christophe.jaillet@wanadoo.fr \
--cc=dlan@gentoo.org \
--cc=elder@ieee.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=sboyd@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=spacemit@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox