lkml.org 
[lkml]   [2008]   [Feb]   [19]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [2.6 patch] drivers/thermal/thermal.c: fix a check-after-use
FromHarvey Harrison <>
DateTue, 19 Feb 2008 16:25:02 -0800
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@kernel.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;
Cheers,

Harvey

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

\
 
 \ /
  Last update: 2008-02-20 01:27    [from the cache]
©2003-2008