Re: [PATCH 1/2] cpufreq: sun50i: fix memory leak in dt_has_supported_hw()

From: Viresh Kumar
Date: Mon May 20 2024 - 04:34:44 EST


On 20-05-24, 09:26, Andre Przywara wrote:
> On Mon, 20 May 2024 13:03:39 +0530
> Viresh Kumar <viresh.kumar@xxxxxxxxxx> wrote:
>
> Hi,
>
> > On 10-05-24, 17:49, Andre Przywara wrote:
> > > On Fri, 03 May 2024 19:52:32 +0200
> > > Javier Carrasco <javier.carrasco.cruz@xxxxxxxxx> wrote:
> > > > diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> > > > index 0b882765cd66..ef83e4bf2639 100644
> > > > --- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> > > > +++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
> > > > @@ -131,7 +131,7 @@ static const struct of_device_id cpu_opp_match_list[] = {
> > > > static bool dt_has_supported_hw(void)
> > > > {
> > > > bool has_opp_supported_hw = false;
> > > > - struct device_node *np, *opp;
> > > > + struct device_node *np;
> >
> > Why is the opp pointer removed ?
>
> Because it's now declared *inside* the for_each_child_of_node_scoped loop
> below, courtesy of this new macro. The idea is that by doing so, any
> "break;" will exit the scope, triggering the cleanup routine. The loop
> running till "the end" will also make "opp" exit its scope, triggering the
> same routine.

Applied. Thanks.

--
viresh