Skip to contentSkip to conversation

leds: mc13783: fix off-by-one for checking num_leds

PATCH In review Axel Lin 2 participants 2 messages Dec 10, 2011 – Dec 12, 2011 LED

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 leds: mc13783: fix off-by-one for checking num_leds

The LED id is begin from 0.
Thus the maximum number of leds should be MC13783_LED_MAX + 1.

---
 drivers/leds/leds-mc13783.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/leds/leds-mc13783.c +1 -1
index c61e8c4..8bc4915 100644
@@ -275,7 +275,7 @@ static int __devinit mc13783_led_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	if (pdata->num_leds < 1 || pdata->num_leds > MC13783_LED_MAX) {
+	if (pdata->num_leds < 1 || pdata->num_leds > (MC13783_LED_MAX + 1)) {
 		dev_err(&pdev->dev, "Invalid led count %d\n", pdata->num_leds);
 		return -EINVAL;
 	}
Signature · 1 line
1.7.5.4
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · Le samedi 10 décembre 2011 15:14:56 Axel Lin a écrit :

The LED id is begin from 0.
Thus the maximum number of leds should be MC13783_LED_MAX + 1.

---
 drivers/leds/leds-mc13783.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/leds/leds-mc13783.c +0 -0
index c61e8c4..8bc4915 100644

drivers/leds/leds-mc13783.c static int __devinit mc13783_led_probe(struct · line 281

Quoted 8 lines
drivers/leds/leds-mc13783.c +1 -1
@@ -275,7 +275,7 @@ static int __devinit mc13783_led_probe(struct
 platform_device *pdev) return -ENODEV;
 	}
 
-	if (pdata->num_leds < 1 || pdata->num_leds > MC13783_LED_MAX) {
+	if (pdata->num_leds < 1 || pdata->num_leds > (MC13783_LED_MAX + 1)) {
 		dev_err(&pdev->dev, "Invalid led count %d\n", pdata->num_leds);
 		return -EINVAL;
 	}

Thanks !

Philippe