All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Masney <bmasney@redhat.com>
To: "Alexander A. Klimov" <grandmaster@al2klimov.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Jonas Jensen <jonas.jensen@gmail.com>,
	Mike Turquette <mturquette@linaro.org>,
	"moderated list:ARM/MOXA ART SOC"
	<linux-arm-kernel@lists.infradead.org>,
	"open list:COMMON CLK FRAMEWORK" <linux-clk@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] clk: moxart: fix refcount leak
Date: Tue, 26 May 2026 13:45:43 -0400	[thread overview]
Message-ID: <ahXcR-T6pyWmV1_e@redhat.com> (raw)
In-Reply-To: <cb81262a-5327-41bb-9ef6-9cd91f1be0f7@al2klimov.de>

Hi Alexander,

On Thu, May 21, 2026 at 06:16:38AM +0200, Alexander A. Klimov wrote:
> On 5/21/26 00:29, Brian Masney wrote:
> > On Wed, May 20, 2026 at 07:55:50PM +0200, Alexander A. Klimov wrote:
> > > Every value returned from of_clk_get() is supposed to be cleaned up
> > > via clk_put() once not needed anymore.
> > > The values here are used only for error checking,
> > > but weren't cleaned up until now.
> > > 
> > > Fixes: c7bb4fc16ead ("clk: add MOXA ART SoCs clock driver")
> > > Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
> > > ---
> > >   drivers/clk/clk-moxart.c | 2 ++
> > >   1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/drivers/clk/clk-moxart.c b/drivers/clk/clk-moxart.c
> > > index 3786a0153ad1..7e191b1481bb 100644
> > > --- a/drivers/clk/clk-moxart.c
> > > +++ b/drivers/clk/clk-moxart.c
> > > @@ -39,6 +39,7 @@ static void __init moxart_of_pll_clk_init(struct device_node *node)
> > >   		pr_err("%pOF: of_clk_get failed\n", node);
> > >   		return;
> > >   	}
> > > +	clk_put(ref_clk);
> > >   	hw = clk_hw_register_fixed_factor(NULL, name, parent_name, 0, mul, 1);
> > >   	if (IS_ERR(hw)) {
> > > @@ -83,6 +84,7 @@ static void __init moxart_of_apb_clk_init(struct device_node *node)
> > >   		pr_err("%pOF: of_clk_get failed\n", node);
> > >   		return;
> > >   	}
> > > +	clk_put(pll_clk);
> > 
> > So this immediately drops the reference to the clk after of_clk_get() is
> > called. Can we just remove these two of_clk_get() calls since they don't
> > appear to be used?
> Not if their purpose is to... idk...
> check whether device_node is a clock at all, maybe?

The clk driver already calls of_clk_get_parent_name(), and it validates
the clock-output-names is valid. The of_clk_get() validations in this driver
are redundant, unless I'm missing something.

Brian


      reply	other threads:[~2026-05-26 17:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20 17:55 [PATCH] clk: moxart: fix refcount leak Alexander A. Klimov
2026-05-20 22:29 ` Brian Masney
2026-05-21  4:16   ` Alexander A. Klimov
2026-05-26 17:45     ` Brian Masney [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=ahXcR-T6pyWmV1_e@redhat.com \
    --to=bmasney@redhat.com \
    --cc=grandmaster@al2klimov.de \
    --cc=jonas.jensen@gmail.com \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=mturquette@linaro.org \
    --cc=sboyd@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.