thermal: fair_share: check for a valid thermal zone device
diff mbox

Message ID 1364637877-28068-1-git-send-email-devendra.aaru@gmail.com
State Rejected
Delegated to: Zhang Rui
Headers show

Commit Message

Devendra Naga March 30, 2013, 10:04 a.m. UTC
to be on safe side check for a valid thermal zone device and fail if there
is no thermal zone device.

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
---
 drivers/thermal/fair_share.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Zhang Rui April 1, 2013, 1:05 a.m. UTC | #1
On Sat, 2013-03-30 at 15:34 +0530, Devendra Naga wrote:
> to be on safe side check for a valid thermal zone device and fail if there
> is no thermal zone device.
> 

> Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
> ---
>  drivers/thermal/fair_share.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/fair_share.c b/drivers/thermal/fair_share.c
> index 792479f..4cd1d47 100644
> --- a/drivers/thermal/fair_share.c
> +++ b/drivers/thermal/fair_share.c
> @@ -85,7 +85,7 @@ static int fair_share_throttle(struct thermal_zone_device *tz, int trip)
>  	int i;
>  	int cur_trip_level = get_trip_level(tz);
>  
> -	if (!tz->tzp || !tz->tzp->tbp)
> +	if (!tz || !tz->tzp || !tz->tzp->tbp)
>  		return -EINVAL;

when tz equals NULL, it suggests a really serious problem, and IMO, a
NULL pointer dereference or Panic in this case is more meaningful.

thanks,
rui

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

Patch
diff mbox

diff --git a/drivers/thermal/fair_share.c b/drivers/thermal/fair_share.c
index 792479f..4cd1d47 100644
--- a/drivers/thermal/fair_share.c
+++ b/drivers/thermal/fair_share.c
@@ -85,7 +85,7 @@  static int fair_share_throttle(struct thermal_zone_device *tz, int trip)
 	int i;
 	int cur_trip_level = get_trip_level(tz);
 
-	if (!tz->tzp || !tz->tzp->tbp)
+	if (!tz || !tz->tzp || !tz->tzp->tbp)
 		return -EINVAL;
 
 	tzp = tz->tzp;