Skip to contentSkip to conversation

leds: mt6323: Fix an off by one bug in probe

PATCH Applied Dan Carpenter 3 participants 3 messages Mar 23, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds: mt6323: Fix an off by one bug in probe

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")
drivers/leds/leds-mt6323.c +1 -1
index 48081bccbea5..8893c74e9a1f 100644
@@ -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;
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dan Carpenter

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")
Quoted 13 lines
drivers/leds/leds-mt6323.c +1 -1
index 48081bccbea5..8893c74e9a1f 100644
@@ -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;
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#2 lore raw
Quoted 8 lines · Pavel Machek
Quoted 5 lines · Dan Carpenter

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")

Applied, thanks.

Signature · 2 lines
Best regards,
Jacek Anaszewski