Commit 877d5cd2 authored by qinyu's avatar qinyu Committed by Rafael J. Wysocki

cpufreq: warn about invalid vals to scaling_max/min_freq interfaces

When echo an invalid val to scaling_min_freq:
> echo 123abc123 > scaling_min_freq
It looks weird to have a return val of 0:
> echo $?
> 0

Sane people won't echo strings like that into these interfaces but fuzz
tests may do. Also, maybe it's better to inform people if input is
invalid.

After this:
> echo 123abc123 > scaling_min_freq
> -bash: echo: write error: Invalid argument
Signed-off-by: default avatarqinyu <qinyu32@huawei.com>
Tested-by: default avatarzhangxiaofeng <zhangxiaofeng46@huawei.com>
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 7a9dec66
......@@ -725,9 +725,9 @@ static ssize_t store_##file_name \
unsigned long val; \
int ret; \
\
ret = sscanf(buf, "%lu", &val); \
if (ret != 1) \
return -EINVAL; \
ret = kstrtoul(buf, 0, &val); \
if (ret) \
return ret; \
\
ret = freq_qos_update_request(policy->object##_freq_req, val);\
return ret >= 0 ? count : ret; \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment