@@ -614,11 +614,16 @@ static ssize_t store_governor(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct devfreq *df = to_devfreq(dev);
- int ret = 0;
+ int ret;
+ char str_governor[DEVFREQ_NAME_LEN + 1];
struct devfreq_governor *governor;
+ ret = sscanf(buf, "%" __stringify(DEVFREQ_NAME_LEN) "s", str_governor);
+ if (ret != 1)
+ return -EINVAL;
+
mutex_lock(&devfreq_list_lock);
- governor = find_devfreq_governor(buf);
+ governor = find_devfreq_governor(str_governor);
if (IS_ERR(governor)) {
ret = PTR_ERR(governor);
goto out;