Skip to content

Commit

Permalink
drivers/leds/leds-mc13783.c: fix off-by-one for checking num_leds
Browse files Browse the repository at this point in the history
The LED id begins from 0.  Thus the maximum number of leds should be
MC13783_LED_MAX + 1.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Philippe Retornaz <philippe.retornaz@epfl.ch>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Axel Lin authored and Linus Torvalds committed Jan 11, 2012
1 parent a6d511e commit 3b08094
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/leds/leds-mc13783.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 3b08094

Please sign in to comment.