Thermal: Remove dangling newline character in buf on policy_store()
Jinyoung Park [Fri, 30 Nov 2012 09:55:51 +0000 (01:55 -0800)]
Can't find governor by name string comparison due to dangling newline
character in buf on policy_store().

Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/167874
(cherry picked from commit 5226b1816b49a0ce733ee332f31d29761a354006)

Change-Id: Ic96ec57b1fa90dd8a2a3fe7a23f4cb8ebc4bb7df
Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/172167
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>

drivers/thermal/thermal_sys.c

index 506cbf2..f153158 100644 (file)
@@ -679,10 +679,14 @@ policy_store(struct device *dev, struct device_attribute *attr,
        int ret = -EINVAL;
        struct thermal_zone_device *tz = to_thermal_zone(dev);
        struct thermal_governor *gov;
+       char name[THERMAL_NAME_LENGTH];
 
        mutex_lock(&thermal_governor_lock);
 
-       gov = __find_governor(buf);
+       if ((strlen(buf) >= THERMAL_NAME_LENGTH) && !sscanf(buf, "%s\n", name))
+               goto exit;
+
+       gov = __find_governor((const char *)name);
        if (!gov)
                goto exit;