Skip to content

Commit 877d5cd

Browse files
qinyurafaeljw
authored andcommitted
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: qinyu <qinyu32@huawei.com> Tested-by: zhangxiaofeng <zhangxiaofeng46@huawei.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 7a9dec6 commit 877d5cd

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/cpufreq/cpufreq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,9 +725,9 @@ static ssize_t store_##file_name \
725725
unsigned long val; \
726726
int ret; \
727727
\
728-
ret = sscanf(buf, "%lu", &val); \
729-
if (ret != 1) \
730-
return -EINVAL; \
728+
ret = kstrtoul(buf, 0, &val); \
729+
if (ret) \
730+
return ret; \
731731
\
732732
ret = freq_qos_update_request(policy->object##_freq_req, val);\
733733
return ret >= 0 ? count : ret; \

0 commit comments

Comments
 (0)