Commit 3b080945 authored by Axel Lin's avatar Axel Lin Committed by Linus Torvalds

drivers/leds/leds-mc13783.c: fix off-by-one for checking num_leds

The LED id begins from 0.  Thus the maximum number of leds should be
MC13783_LED_MAX + 1.
Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Acked-by: default avatarPhilippe Retornaz <philippe.retornaz@epfl.ch>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a6d511e5
...@@ -275,7 +275,7 @@ static int __devinit mc13783_led_probe(struct platform_device *pdev) ...@@ -275,7 +275,7 @@ static int __devinit mc13783_led_probe(struct platform_device *pdev)
return -ENODEV; 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); dev_err(&pdev->dev, "Invalid led count %d\n", pdata->num_leds);
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment