Re: [PATCH] clk: moxart: fix refcount leak

From: Brian Masney

Date: Tue May 26 2026 - 13:46:01 EST


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@xxxxxxxxxxxx>
> > > ---
> > > 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