leds: mc13783: fix off-by-one for checking num_leds
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.
Signed-off-by Axel Lin <[email protected]>
--- drivers/leds/leds-mc13783.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
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 ; }
Signature · 1 line
1.7.5.4
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 beMC13783_LED_MAX+ 1.Signed-off-by Axel Lin <[email protected]>--- drivers/leds/leds-mc13783.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/leds/leds-mc13783.c +0
-0
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