Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PM / devfreq: governor: Replace sscanf() with kstrtoul() in set_freq_store()

Replace sscanf() with kstrtoul() in set_freq_store() and check the result
to avoid invalid input.

Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
Link: https://lore.kernel.org/lkml/20250421030020.3108405-2-zhenglifeng1@huawei.com/
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

authored by

Lifeng Zheng and committed by
Chanwoo Choi
914cc799 347e9f50

+5 -1
+5 -1
drivers/devfreq/governor_userspace.c
··· 9 9 #include <linux/slab.h> 10 10 #include <linux/device.h> 11 11 #include <linux/devfreq.h> 12 + #include <linux/kstrtox.h> 12 13 #include <linux/pm.h> 13 14 #include <linux/mutex.h> 14 15 #include <linux/module.h> ··· 40 39 unsigned long wanted; 41 40 int err = 0; 42 41 42 + err = kstrtoul(buf, 0, &wanted); 43 + if (err) 44 + return err; 45 + 43 46 mutex_lock(&devfreq->lock); 44 47 data = devfreq->governor_data; 45 48 46 - sscanf(buf, "%lu", &wanted); 47 49 data->user_frequency = wanted; 48 50 data->valid = true; 49 51 err = update_devfreq(devfreq);