lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240520092623.6ce850e1@donnerap.manchester.arm.com>
Date: Mon, 20 May 2024 09:26:23 +0100
From: Andre Przywara <andre.przywara@....com>
To: Viresh Kumar <viresh.kumar@...aro.org>
Cc: Javier Carrasco <javier.carrasco.cruz@...il.com>, Yangtao Li
 <tiny.windzz@...il.com>, "Rafael J. Wysocki" <rafael@...nel.org>, Chen-Yu
 Tsai <wens@...e.org>, Jernej Skrabec <jernej.skrabec@...il.com>, Samuel
 Holland <samuel@...lland.org>, Jonathan Cameron
 <Jonathan.Cameron@...wei.com>, linux-pm@...r.kernel.org,
 linux-arm-kernel@...ts.infradead.org, linux-sunxi@...ts.linux.dev,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] cpufreq: sun50i: fix memory leak in
 dt_has_supported_hw()

On Mon, 20 May 2024 13:03:39 +0530
Viresh Kumar <viresh.kumar@...aro.org> 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@...il.com> 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.

Cheers,
Andre

> 
> > >  	struct device *cpu_dev;
> > >  
> > >  	cpu_dev = get_cpu_device(0);
> > > @@ -142,7 +142,7 @@ static bool dt_has_supported_hw(void)
> > >  	if (!np)
> > >  		return false;
> > >  
> > > -	for_each_child_of_node(np, opp) {
> > > +	for_each_child_of_node_scoped(np, opp) {
> > >  		if (of_find_property(opp, "opp-supported-hw", NULL)) {
> > >  			has_opp_supported_hw = true;
> > >  			break;
> > >   
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ