[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zs8hRPA9Lya29d6d@smile.fi.intel.com>
Date: Wed, 28 Aug 2024 16:08:20 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Stephen Boyd <sboyd@...nel.org>
Cc: linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org,
Michael Turquette <mturquette@...libre.com>,
Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
Subject: Re: [PATCH v1 1/1] clk: devres: Simplify devres handling functions
On Tue, Aug 27, 2024 at 05:19:04PM -0700, Stephen Boyd wrote:
> Quoting Andy Shevchenko (2024-08-22 08:58:22)
...
> > - state = devres_alloc(devm_clk_release, sizeof(*state), GFP_KERNEL);
> > + state = devm_kmalloc(dev, sizeof(*state), GFP_KERNEL);
>
> When is this allocation freed if the get() fails? When the calling
> device driver detaches?
At device unbinding. Is it a problem?
...
> > + ret = devm_add_action_or_reset(dev, devm_clk_release, state);
> > + if (ret)
> > + goto err_clk_init;
>
> Shouldn't we return an error here? Otherwise we call clk_put() twice?
Or use devm_add_action().
Thanks for catching this!
> > return clk;
> >
> > err_clk_init:
> > clk_put(clk);
> > return ERR_PTR(ret);
> > }
...
> I stopped reading, sorry! If you want to do this, please add a bunch of
> KUnit tests.
Sure. It's a good idea.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists