Skip to contentSkip to conversation

thermal: fair_share: check for a valid thermal zone device

PATCH In review Devendra Naga 2 participants 2 messages Mar 30, 2013 – Apr 1, 2013 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal: fair_share: check for a valid thermal zone device

to be on safe side check for a valid thermal zone device and fail if there is no thermal zone device.

---
 drivers/thermal/fair_share.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/fair_share.c +1 -1
index 792479f..4cd1d47 100644
@@ -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;
Signature · 1 line
1.8.1.4
reviewer
#1 lore raw
Quoted 14 lines · Devendra Naga

to be on safe side check for a valid thermal zone device and fail if there is no thermal zone device.

---
 drivers/thermal/fair_share.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/fair_share.c +0 -0
index 792479f..4cd1d47 100644

drivers/thermal/fair_share.c static int fair_share_throttle(struct thermal_zone_device *tz, int trip) · line 89

Quoted 6 lines
drivers/thermal/fair_share.c +1 -1
@@ -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