lkml.org 
[lkml]   [2019]   [Oct]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] platform/x86: huawei-wmi: make validation stricter in huawei_wmi_battery_set()
I don't think it makes sense for "end" to be negative or for even for it
to be less than "start". That also means that "start" can't be more
than 100 which is good.

Fixes: b7527d0f4502 ("platform/x86: huawei-wmi: Add battery charging thresholds")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/platform/x86/huawei-wmi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/huawei-wmi.c b/drivers/platform/x86/huawei-wmi.c
index 6720f78c60c2..02a505a72172 100644
--- a/drivers/platform/x86/huawei-wmi.c
+++ b/drivers/platform/x86/huawei-wmi.c
@@ -343,7 +343,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 < start || end > 100)
return -EINVAL;

arg.cmd = BATTERY_THRESH_SET;
--
2.20.1
\
 
 \ /
  Last update: 2019-10-15 10:40    [W:0.048 / U:0.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site