]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
PM / devfreq: fix sscanf handling for writable sysfs entries
authorNishanth Menon <nm@ti.com>
Wed, 24 Oct 2012 00:39:02 +0000 (02:39 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 24 Oct 2012 00:39:02 +0000 (02:39 +0200)
sscanf returns 0 when an invalid parameter like:
echo -n "a">min_freq
is attempted. Returning back the return result(0) will
cause the command not to return back to command
prompt.

Instead, just return -EINVAL when sscanf does not
return 1.

This is done for min_freq, max_freq and polling_interval

Signed-off-by: Nishanth Menon <nm@ti.com>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/devfreq/devfreq.c

index f56c41d2100b3409b6d6c7a48992f5333ac29f25..f47b07c7996e5054a8eabe753b4e4dcca9a46262 100644 (file)
@@ -497,12 +497,11 @@ static ssize_t store_polling_interval(struct device *dev,
 
        ret = sscanf(buf, "%u", &value);
        if (ret != 1)
-               goto out;
+               return -EINVAL;
 
        df->governor->event_handler(df, DEVFREQ_GOV_INTERVAL, &value);
        ret = count;
 
-out:
        return ret;
 }
 
@@ -516,7 +515,7 @@ static ssize_t store_min_freq(struct device *dev, struct device_attribute *attr,
 
        ret = sscanf(buf, "%lu", &value);
        if (ret != 1)
-               goto out;
+               return -EINVAL;
 
        mutex_lock(&df->lock);
        max = df->max_freq;
@@ -530,7 +529,6 @@ static ssize_t store_min_freq(struct device *dev, struct device_attribute *attr,
        ret = count;
 unlock:
        mutex_unlock(&df->lock);
-out:
        return ret;
 }
 
@@ -550,7 +548,7 @@ static ssize_t store_max_freq(struct device *dev, struct device_attribute *attr,
 
        ret = sscanf(buf, "%lu", &value);
        if (ret != 1)
-               goto out;
+               return -EINVAL;
 
        mutex_lock(&df->lock);
        min = df->min_freq;
@@ -564,7 +562,6 @@ static ssize_t store_max_freq(struct device *dev, struct device_attribute *attr,
        ret = count;
 unlock:
        mutex_unlock(&df->lock);
-out:
        return ret;
 }