public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Darren Hart <dvhart@infradead.org>,
	Ayman Bagabas <ayman.bagabas@gmail.com>
Cc: Andy Shevchenko <andy@infradead.org>,
	Takashi Iwai <tiwai@suse.de>, Mattias Jacobsson <2pi@mok.nu>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] platform/x86: huawei-wmi: make validation stricter in huawei_wmi_battery_set()
Date: Tue, 15 Oct 2019 11:38:38 +0300	[thread overview]
Message-ID: <20191015083837.GA29104@mwanda> (raw)

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


             reply	other threads:[~2019-10-15  8:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15  8:38 Dan Carpenter [this message]
     [not found] ` <CAB3uXr63uUwxBjkeeoftZ6HYm_hmN+E5EUhu15_Mta2qruOugA@mail.gmail.com>
2019-10-15 12:46   ` [PATCH] platform/x86: huawei-wmi: make validation stricter in huawei_wmi_battery_set() Dan Carpenter
2019-10-15 13:20     ` ayman.bagabas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191015083837.GA29104@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=2pi@mok.nu \
    --cc=andy@infradead.org \
    --cc=ayman.bagabas@gmail.com \
    --cc=dvhart@infradead.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox