From: Shuah Khan <skhan@linuxfoundation.org>
To: Brahadambal Srinivasan <latha@linux.vnet.ibm.com>,
shuah@kernel.org, trenn@suse.com
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] cpuidle_set accepts alpha numeric values for idle-set operation
Date: Tue, 5 Jan 2021 11:13:21 -0700 [thread overview]
Message-ID: <b6060801-9477-a61b-abb5-b6eecf5940c9@linuxfoundation.org> (raw)
In-Reply-To: <e2234e38-e18e-e0d3-1a2a-7c8b136d8817@linuxfoundation.org>
On 1/5/21 11:03 AM, Shuah Khan wrote:
> On 1/5/21 5:24 AM, Brahadambal Srinivasan wrote:
>> For both the d and e options in cpuidle_set, an atoi() conversion is
>> done without checking if the input argument is all numeric. So, an
>> atoi conversion is done on any character provided as input and the
>> CPU idle_set operation continues with that integer value, which may
>> not be what is intended or entirely correct.
>>
>> A similar check is present for cpufreq-set already.
>>
>> This patch adds a check to see that the idle_set value is all numeric
>> before doing a string-to-int conversion.
>>
>> Signed-off-by: Brahadambal Srinivasan <latha@linux.vnet.ibm.com>
>> ---
>> tools/power/cpupower/utils/cpuidle-set.c | 39 +++++++++++++++++++++---
>> 1 file changed, 34 insertions(+), 5 deletions(-)
>>
>> diff --git a/tools/power/cpupower/utils/cpuidle-set.c
>> b/tools/power/cpupower/utils/cpuidle-set.c
>> index 46158928f9ad..b3dec48e7141 100644
>> --- a/tools/power/cpupower/utils/cpuidle-set.c
>> +++ b/tools/power/cpupower/utils/cpuidle-set.c
>> @@ -21,6 +21,19 @@ static struct option info_opts[] = {
>> { },
>> };
>> +int is_number(char *arg)
>> +{
>> + size_t len, i = 0;
>> +
>> + len = strlen(arg);
>> +
>> + for (i = 0; i < len; i++) {
>> + if (!isdigit(arg[i]))
>> + return 0;
>> + }
>> +
>> + return 1;
>> +}
>
> Any reason why you can't use isdigit()? Please see isdigit()
> usages examples in other tools and cpupower itself.
>
Another thing. Please add "cpupower:" to identify what you are
changing clearly.
thanks,
-- Shuah
next prev parent reply other threads:[~2021-01-05 18:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-05 12:24 [PATCH] cpuidle_set accepts alpha numeric values for idle-set operation Brahadambal Srinivasan
2021-01-05 18:03 ` Shuah Khan
2021-01-05 18:13 ` Shuah Khan [this message]
2021-01-05 19:51 ` Shuah Khan
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=b6060801-9477-a61b-abb5-b6eecf5940c9@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=latha@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=trenn@suse.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