From: Andreas Kemnade <andreas@kemnade.info>
To: Miaoqian Lin <linmq006@gmail.com>
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>,
Kevin Hilman <khilman@baylibre.com>,
Roger Quadros <rogerq@kernel.org>,
Tony Lindgren <tony@atomide.com>,
linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-clk@vger.kernel.org
Subject: Re: [PATCH] bus: ti-sysc: Fix potential double free in sysc_add_named_clock_from_child()
Date: Mon, 11 Aug 2025 16:53:58 +0200 [thread overview]
Message-ID: <20250811165358.79b3128c@akair> (raw)
In-Reply-To: <20250804120403.97959-1-linmq006@gmail.com>
Hi,
Am Mon, 4 Aug 2025 20:04:03 +0800
schrieb Miaoqian Lin <linmq006@gmail.com>:
> The devm_get_clk_from_child() function uses device-managed resources
> that are automatically cleaned up. The clk_put() call after
> devm_get_clk_from_child() is redundant and
> may lead to double-free issues.
>
> Fixes: a54275f4ab20 ("bus: ti-sysc: Add quirk handling for external optional functional clock")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
> drivers/bus/ti-sysc.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
> index 9f624e5da991..5441b0739faa 100644
> --- a/drivers/bus/ti-sysc.c
> +++ b/drivers/bus/ti-sysc.c
> @@ -362,7 +362,6 @@ static int sysc_add_named_clock_from_child(struct sysc *ddata,
> cl->clk = clock;
> clkdev_add(cl);
>
> - clk_put(clock);
>
> return 0;
> }
I understand the double-free issue, but I have some questions to make
sure I understand it correctly what we are doing here. So lets ask the
possibly stupid questions and check assumptions:
- clk_hw hardware still lives after clk_put(), so we do not have
problems normally here after that put when we do not remove the
device?
- With your patch the put is delayed, so things live longer. So why
we do not use devm_clk_put() or avoid using devres at all here?
Regards,
Andreas
next parent reply other threads:[~2025-08-11 15:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250804120403.97959-1-linmq006@gmail.com>
2025-08-11 14:53 ` Andreas Kemnade [this message]
2025-08-18 3:23 ` [PATCH] bus: ti-sysc: Fix potential double free in sysc_add_named_clock_from_child() 林妙倩
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=20250811165358.79b3128c@akair \
--to=andreas@kemnade.info \
--cc=aaro.koskinen@iki.fi \
--cc=khilman@baylibre.com \
--cc=linmq006@gmail.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=rogerq@kernel.org \
--cc=tony@atomide.com \
/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;
as well as URLs for NNTP newsgroup(s).