platform/x86: huawei-wmi: Stricter battery thresholds set
authorAyman Bagabas <ayman.bagabas@gmail.com>
Sun, 20 Oct 2019 17:00:07 +0000 (13:00 -0400)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 21 Oct 2019 09:17:30 +0000 (12:17 +0300)
Check if battery thresholds are within 0 and 100.

Fixes: 355a070b09ab ("platform/x86: huawei-wmi: Add battery charging thresholds")
Signed-off-by: Ayman Bagabas <ayman.bagabas@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
drivers/platform/x86/huawei-wmi.c

index 5837d1b..26041d4 100644 (file)
@@ -345,7 +345,7 @@ static int huawei_wmi_battery_set(int start, int end)
        union hwmi_arg arg;
        int err;
 
-       if (start < 0 || end > 100)
+       if (start < 0 || end < 0 || start > 100 || end > 100)
                return -EINVAL;
 
        arg.cmd = BATTERY_THRESH_SET;