From: Allen Martin Date: Thu, 30 Jun 2011 23:59:19 +0000 (-0700) Subject: cpufreq: interactive: Add error checking on sysfs interfaces X-Git-Tag: firefly_0821_release~7613^2~427 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8b12552d248d574b6e333a6e120bccb2abe4010a;p=firefly-linux-kernel-4.4.55.git cpufreq: interactive: Add error checking on sysfs interfaces This adds better error checking on tunable parameters on sysfs interfaces. Also fixes return value from these functions, previously on success they would return 0 which would cause a infinite loop. Change-Id: Ic05038492166f8673d007202092471f98a2f0dfa Signed-off-by: Allen Martin --- diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c index 9100c3b6adf5..fe20e3142c6e 100644 --- a/drivers/cpufreq/cpufreq_interactive.c +++ b/drivers/cpufreq/cpufreq_interactive.c @@ -394,7 +394,14 @@ static ssize_t show_go_maxspeed_load(struct kobject *kobj, static ssize_t store_go_maxspeed_load(struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) { - return strict_strtoul(buf, 0, &go_maxspeed_load); + int ret; + unsigned long val; + + ret = strict_strtoul(buf, 0, &val); + if (ret < 0) + return ret; + go_maxspeed_load = val; + return count; } static struct global_attr go_maxspeed_load_attr = __ATTR(go_maxspeed_load, 0644, @@ -409,7 +416,14 @@ static ssize_t show_min_sample_time(struct kobject *kobj, static ssize_t store_min_sample_time(struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) { - return strict_strtoul(buf, 0, &min_sample_time); + int ret; + unsigned long val; + + ret = strict_strtoul(buf, 0, &val); + if (ret < 0) + return ret; + min_sample_time = val; + return count; } static struct global_attr min_sample_time_attr = __ATTR(min_sample_time, 0644,