thermal: fair_share: check for a valid thermal zone device
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.
Signed-off-by Devendra Naga <[email protected]>
--- drivers/thermal/fair_share.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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 ; tzp = tz->tzp;
Signature · 1 line
1.8.1.4
Zhang Rui
reviewerQuoted 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.
Signed-off-by Devendra Naga <[email protected]>--- drivers/thermal/fair_share.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/thermal/fair_share.c +0
-0
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