summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorAndrew Lutomirski <luto@kernel.org>2016-11-29 17:11:50 -0800
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-11-30 22:34:23 +0100
commitee061da8d9dfc30ced06f25c18694cffa70eac1e (patch)
tree0a0b869ef3b1bf294ec76223bc497933fea26a92 /drivers/base
parente5517c2a5a49ed5e99047008629f1cd60246ea0e (diff)
PM / QoS: Improve sysfs pm_qos_latency_tolerance validation
Negative values are special. Don't let users write them directly. Signed-off-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/power/sysfs.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index a7b46798c81d..33b4b902741a 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -263,7 +263,11 @@ static ssize_t pm_qos_latency_tolerance_store(struct device *dev,
s32 value;
int ret;
- if (kstrtos32(buf, 0, &value)) {
+ if (kstrtos32(buf, 0, &value) == 0) {
+ /* Users can't write negative values directly */
+ if (value < 0)
+ return -EINVAL;
+ } else {
if (!strcmp(buf, "auto") || !strcmp(buf, "auto\n"))
value = PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT;
else if (!strcmp(buf, "any") || !strcmp(buf, "any\n"))