Skip to content

Commit 1da98dc

Browse files
Bowen Yurafaeljw
authored andcommitted
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 <yubowen8@huawei.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Link: https://patch.msgid.link/20250519070938.931396-1-yubowen8@huawei.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 9c5075f commit 1da98dc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -917,9 +917,9 @@ static ssize_t store_scaling_setspeed(struct cpufreq_policy *policy,
917917
if (!policy->governor || !policy->governor->store_setspeed)
918918
return -EINVAL;
919919

920-
ret = sscanf(buf, "%u", &freq);
921-
if (ret != 1)
922-
return -EINVAL;
920+
ret = kstrtouint(buf, 0, &freq);
921+
if (ret)
922+
return ret;
923923

924924
policy->governor->store_setspeed(policy, freq);
925925

0 commit comments

Comments
 (0)