From: Bowen Yu Date: Mon, 19 May 2025 07:09:38 +0000 (+0800) Subject: cpufreq: Update sscanf() to kstrtouint() X-Git-Tag: v6.16-rc1~160^2~3^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1da98dc52b948a6063415d8bae0c60ef89044a8c;p=thirdparty%2Flinux.git cpufreq: Update sscanf() to kstrtouint() In store_scaling_setspeed(), sscanf is still used to read to sysfs. Newer kstrtox provide more features including overflow protection, better errorhandling and allows for other systems of numeration. It is therefore better to update sscanf() to kstrtouint(). Signed-off-by: Bowen Yu Acked-by: Viresh Kumar Link: https://patch.msgid.link/20250519070938.931396-1-yubowen8@huawei.com Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index fbd09c0845ff7..d7426e1d8bdd2 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -917,9 +917,9 @@ static ssize_t store_scaling_setspeed(struct cpufreq_policy *policy, if (!policy->governor || !policy->governor->store_setspeed) return -EINVAL; - ret = sscanf(buf, "%u", &freq); - if (ret != 1) - return -EINVAL; + ret = kstrtouint(buf, 0, &freq); + if (ret) + return ret; policy->governor->store_setspeed(policy, freq);