Thermal: Fix potential NULL pointer dereference bug on tz->governor
Jinyoung Park [Tue, 8 Jan 2013 12:53:32 +0000 (21:53 +0900)]
Fix potential NULL pointer dereference bug on tz->governor when
governor_name is not valid.

Bug 1200111

Change-Id: I911bdeb812f48f86f241e1a51d0af41080b62022
Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/189546
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Matthew Longnecker <mlongnecker@nvidia.com>
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>

drivers/thermal/thermal_sys.c

index 6d96518..5979b6e 100644 (file)
@@ -1679,8 +1679,14 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
 
        if (tz->tzp)
                tz->governor = __find_governor(tz->tzp->governor_name);
-       else
+
+       if (!tz->governor) {
                tz->governor = __find_governor(DEFAULT_THERMAL_GOVERNOR);
+               if (!tz->governor) {
+                       mutex_unlock(&thermal_governor_lock);
+                       goto unregister;
+               }
+       }
 
        mutex_unlock(&thermal_governor_lock);