From: qinyu <qinyu32@huawei.com>
To: <rafael@kernel.org>
Cc: <hewenliang4@huawei.com>, <linfeilong@huawei.com>,
<linux-pm@vger.kernel.org>, <qinyu32@huawei.com>,
<viresh.kumar@linaro.org>, <zhangxiaofeng46@huawei.com>,
<yumpusamongus@gmail.com>
Subject: [PATCH v2] cpufreq: warn about invalid vals to scaling_max/min_freq interfaces
Date: Mon, 20 Mar 2023 16:17:02 +0800 [thread overview]
Message-ID: <20230320081702.203843-1-qinyu32@huawei.com> (raw)
In-Reply-To: <CAJZ5v0gFpdWih3Z4Jy6O8t9qz64w1md00ZcQY_exEn9+rC1BOw@mail.gmail.com>
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>
---
v2:
- reword commit message to match the actual code changes.
drivers/cpufreq/cpufreq.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 6d8fd3b8d..d61f7308f 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -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; \
--
2.33.0
next prev parent reply other threads:[~2023-03-20 8:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-16 3:15 [PATCH] cpufreq: warn about invalid vals to scaling_max/min_freq interfaces qinyu
2023-03-16 3:36 ` Viresh Kumar
2023-03-17 11:47 ` Russell Haley
2023-03-20 7:36 ` qinyu
2023-03-17 15:41 ` Rafael J. Wysocki
2023-03-20 8:17 ` qinyu [this message]
2023-03-22 19:12 ` [PATCH v2] " Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230320081702.203843-1-qinyu32@huawei.com \
--to=qinyu32@huawei.com \
--cc=hewenliang4@huawei.com \
--cc=linfeilong@huawei.com \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=viresh.kumar@linaro.org \
--cc=yumpusamongus@gmail.com \
--cc=zhangxiaofeng46@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox