public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] leds: mt6323: Fix an off by one bug in probe
@ 2017-03-23 10:40 Dan Carpenter
  2017-03-23 11:16 ` Pavel Machek
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2017-03-23 10:40 UTC (permalink / raw)
  To: Richard Purdie, Sean Wang
  Cc: kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Jacek Anaszewski,
	Pavel Machek, Matthias Brugger, linux-leds-u79uwXL29TY76Z2rM5mHXA

It should be ">= MT6323_MAX_LEDS" instead of ">".  Also "reg" is a u32
so it can't be negative and we can remove the test for negative values.

Fixes: 216ec6cc4c19 ("leds: Add LED support for MT6323 PMIC")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/leds/leds-mt6323.c b/drivers/leds/leds-mt6323.c
index 48081bccbea5..8893c74e9a1f 100644
--- a/drivers/leds/leds-mt6323.c
+++ b/drivers/leds/leds-mt6323.c
@@ -417,7 +417,7 @@ static int mt6323_led_probe(struct platform_device *pdev)
 			goto put_child_node;
 		}
 
-		if (reg < 0 || reg > MT6323_MAX_LEDS || leds->led[reg]) {
+		if (reg >= MT6323_MAX_LEDS || leds->led[reg]) {
 			dev_err(dev, "Invalid led reg %u\n", reg);
 			ret = -EINVAL;
 			goto put_child_node;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] leds: mt6323: Fix an off by one bug in probe
  2017-03-23 10:40 [PATCH] leds: mt6323: Fix an off by one bug in probe Dan Carpenter
@ 2017-03-23 11:16 ` Pavel Machek
  2017-03-23 19:37   ` Jacek Anaszewski
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2017-03-23 11:16 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Richard Purdie, Sean Wang, Jacek Anaszewski, Matthias Brugger,
	linux-leds, linux-mediatek, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1040 bytes --]

On Thu 2017-03-23 13:40:49, Dan Carpenter wrote:
> It should be ">= MT6323_MAX_LEDS" instead of ">".  Also "reg" is a u32
> so it can't be negative and we can remove the test for negative values.
> 
> Fixes: 216ec6cc4c19 ("leds: Add LED support for MT6323 PMIC")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Acked-by: Pavel Machek <pavel@ucw.cz>


> diff --git a/drivers/leds/leds-mt6323.c b/drivers/leds/leds-mt6323.c
> index 48081bccbea5..8893c74e9a1f 100644
> --- a/drivers/leds/leds-mt6323.c
> +++ b/drivers/leds/leds-mt6323.c
> @@ -417,7 +417,7 @@ static int mt6323_led_probe(struct platform_device *pdev)
>  			goto put_child_node;
>  		}
>  
> -		if (reg < 0 || reg > MT6323_MAX_LEDS || leds->led[reg]) {
> +		if (reg >= MT6323_MAX_LEDS || leds->led[reg]) {
>  			dev_err(dev, "Invalid led reg %u\n", reg);
>  			ret = -EINVAL;
>  			goto put_child_node;

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] leds: mt6323: Fix an off by one bug in probe
  2017-03-23 11:16 ` Pavel Machek
@ 2017-03-23 19:37   ` Jacek Anaszewski
  0 siblings, 0 replies; 3+ messages in thread
From: Jacek Anaszewski @ 2017-03-23 19:37 UTC (permalink / raw)
  To: Pavel Machek, Dan Carpenter
  Cc: Richard Purdie, Sean Wang, Matthias Brugger, linux-leds,
	linux-mediatek, kernel-janitors

On 03/23/2017 12:16 PM, Pavel Machek wrote:
> On Thu 2017-03-23 13:40:49, Dan Carpenter wrote:
>> It should be ">= MT6323_MAX_LEDS" instead of ">".  Also "reg" is a u32
>> so it can't be negative and we can remove the test for negative values.
>>
>> Fixes: 216ec6cc4c19 ("leds: Add LED support for MT6323 PMIC")
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> Acked-by: Pavel Machek <pavel@ucw.cz>

Applied, thanks.

-- 
Best regards,
Jacek Anaszewski

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-23 19:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-23 10:40 [PATCH] leds: mt6323: Fix an off by one bug in probe Dan Carpenter
2017-03-23 11:16 ` Pavel Machek
2017-03-23 19:37   ` Jacek Anaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox