From fa642d9d6e502fbdbd1122a6a247c8ad17063a29 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 6 Aug 2014 08:24:00 +0800 Subject: [PATCH] hwmon: (lm87) Fix vrm write operation vrm is an u8, so the written value needs to be limited to [0, 255]. Signed-off-by: Axel Lin Signed-off-by: Guenter Roeck --- drivers/hwmon/lm87.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index ba1d83d48056..a5e295826aea 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -617,6 +617,10 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, err = kstrtoul(buf, 10, &val); if (err) return err; + + if (val > 255) + return -EINVAL; + data->vrm = val; return count; }