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: <20080220002614.GY31955@cs181133002.pp.htv.fi>
Date:	Wed, 20 Feb 2008 02:26:14 +0200
From:	Adrian Bunk <bunk@...nel.org>
To:	Harvey Harrison <harvey.harrison@...il.com>
Cc:	Zhang Rui <rui.zhang@...el.com>,
	Thomas Sujith <sujith.thomas@...el.com>,
	Len Brown <len.brown@...el.com>, linux-acpi@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [2.6 patch] drivers/thermal/thermal.c: fix a check-after-use

On Tue, Feb 19, 2008 at 04:25:02PM -0800, Harvey Harrison wrote:
> On Wed, 2008-02-20 at 02:14 +0200, Adrian Bunk wrote:
> > This patch fixes a check-after-use spotted by the Coverity checker.
> > 
> > Signed-off-by: Adrian Bunk <bunk@...nel.org>
> > 
> > ---
> > 570462ca4441d8d63dfd46efe6e5b2b1c251a611 diff --git a/drivers/thermal/thermal.c b/drivers/thermal/thermal.c
> > index e782b3e..958654b 100644
> > --- a/drivers/thermal/thermal.c
> > +++ b/drivers/thermal/thermal.c
> > @@ -308,10 +308,10 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
> >  	struct thermal_cooling_device_instance *pos;
> >  	int result;
> >  
> > -	if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE))
> > +	if (!tz || !cdev)
> >  		return -EINVAL;
> >  
> > -	if (!tz || !cdev)
> > +	if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE))
> >  		return -EINVAL;
> >  
> 
> How about:
> 	if (!tz || !cdev || trip >= tz->trips ||
> 	    (trip < 0 && trip != THERMAL_TRIPS_NONE))
> 		return -EINVAL;

I have no strong opinion about it, but I'd consider your suggestion less 
readable.

> Cheers,
> 
> Harvey

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ