diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2014-02-07 02:44:00 -0800 |
---|---|---|
committer | Diwakar Tundlam <dtundlam@nvidia.com> | 2014-02-10 16:04:12 -0800 |
commit | eb68d2851b21ce2297e10dbd201e81e6742e08a6 (patch) | |
tree | e2131c8c9293f652bdbce183aac62fcdd42b978a /drivers/thermal | |
parent | 925697bd2e33a58bfe7edfa7cf3c9e987f223d49 (diff) |
thermal: cut the spaces when user sets policy
Setting policy results in invalid value error.
% echo "step_wise" > policy
% echo: write error: Invalid argument
Need clean up of the buffer which "echo" may add based on the arguments, before
comparing aganist list of governor names.
Change-Id: Ifbb8db53b58c166e2328ddd64618dd9bdec07c78
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reported-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Acked-by: Eduardo Valentin <eduardo.valentin@ti.com>
Tested-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Paul Walmsley <pwalmsley@nvidia.com> # for the NVIDIA downstream kernel
Reviewed-on: http://git-master/r/356874
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
Tested-by: Diwakar Tundlam <dtundlam@nvidia.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/thermal_core.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index f007d0dbbe0f..0063050f09e9 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -33,6 +33,7 @@ #include <linux/idr.h> #include <linux/thermal.h> #include <linux/reboot.h> +#include <linux/string.h> #include <net/netlink.h> #include <net/genetlink.h> #define CREATE_TRACE_POINTS @@ -778,12 +779,14 @@ policy_store(struct device *dev, struct device_attribute *attr, struct thermal_governor *gov; char name[THERMAL_NAME_LENGTH]; + snprintf(name, sizeof(name), "%s", buf); + mutex_lock(&thermal_governor_lock); if ((strlen(buf) >= THERMAL_NAME_LENGTH) || !sscanf(buf, "%s\n", name)) goto exit; - gov = __find_governor((const char *)name); + gov = __find_governor((const char *)strim(name)); if (!gov) goto exit; |