From: David Laight <david.laight.linux@gmail.com>
To: Lifeng Zheng <zhenglifeng1@huawei.com>
Cc: <myungjoo.ham@samsung.com>, <kyungmin.park@samsung.com>,
<cw00.choi@samsung.com>, <linux-pm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linuxarm@huawei.com>,
<jonathan.cameron@huawei.com>, <zhanjie9@hisilicon.com>,
<lihuisong@huawei.com>, <yubowen8@huawei.com>,
<cenxinghai@h-partners.com>
Subject: Re: [PATCH 1/4] PM / devfreq: governor: Replace sscanf() with kstrtoul() in set_freq_store()
Date: Sun, 27 Apr 2025 12:17:04 +0100 [thread overview]
Message-ID: <20250427121704.51e3af2a@pumpkin> (raw)
In-Reply-To: <20250421030020.3108405-2-zhenglifeng1@huawei.com>
On Mon, 21 Apr 2025 11:00:17 +0800
Lifeng Zheng <zhenglifeng1@huawei.com> wrote:
> Replace sscanf() with kstrtoul() in set_freq_store() and check the result
> to avoid invalid input.
Isn't this a UAPI change?
The sscanf() version will ignore trailing characters.
In this case it is actually likely that value might have a trailing "Hz".
David
>
> Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
> ---
> drivers/devfreq/governor_userspace.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/devfreq/governor_userspace.c b/drivers/devfreq/governor_userspace.c
> index d1aa6806b683..175de0c0b50e 100644
> --- a/drivers/devfreq/governor_userspace.c
> +++ b/drivers/devfreq/governor_userspace.c
> @@ -9,6 +9,7 @@
> #include <linux/slab.h>
> #include <linux/device.h>
> #include <linux/devfreq.h>
> +#include <linux/kstrtox.h>
> #include <linux/pm.h>
> #include <linux/mutex.h>
> #include <linux/module.h>
> @@ -39,10 +40,13 @@ static ssize_t set_freq_store(struct device *dev, struct device_attribute *attr,
> unsigned long wanted;
> int err = 0;
>
> + err = kstrtoul(buf, 0, &wanted);
> + if (err)
> + return err;
> +
> mutex_lock(&devfreq->lock);
> data = devfreq->governor_data;
>
> - sscanf(buf, "%lu", &wanted);
> data->user_frequency = wanted;
> data->valid = true;
> err = update_devfreq(devfreq);
next prev parent reply other threads:[~2025-04-27 11:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-21 3:00 [PATCH 0/4] PM / devfreq: Some optimizations of devfreq Lifeng Zheng
2025-04-21 3:00 ` [PATCH 1/4] PM / devfreq: governor: Replace sscanf() with kstrtoul() in set_freq_store() Lifeng Zheng
2025-04-27 11:17 ` David Laight [this message]
2025-04-28 8:07 ` zhenglifeng (A)
2025-05-13 17:19 ` Chanwoo Choi
2025-04-21 3:00 ` [PATCH 2/4] PM / devfreq: Limit max_freq with scaling_min_freq Lifeng Zheng
2025-05-13 17:39 ` Chanwoo Choi
2025-04-21 3:00 ` [PATCH 3/4] PM / devfreq: Remove redundant devfreq_get_freq_range() calling in devfreq_add_device() Lifeng Zheng
2025-05-13 17:41 ` Chanwoo Choi
2025-04-21 3:00 ` [PATCH 4/4] PM / devfreq: Check governor before using governor->name Lifeng Zheng
2025-05-13 17:43 ` Chanwoo Choi
2025-05-13 12:52 ` [PATCH 0/4] PM / devfreq: Some optimizations of devfreq zhenglifeng (A)
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=20250427121704.51e3af2a@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=cenxinghai@h-partners.com \
--cc=cw00.choi@samsung.com \
--cc=jonathan.cameron@huawei.com \
--cc=kyungmin.park@samsung.com \
--cc=lihuisong@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=myungjoo.ham@samsung.com \
--cc=yubowen8@huawei.com \
--cc=zhanjie9@hisilicon.com \
--cc=zhenglifeng1@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.