leds: mt6323: Fix an off by one bug in probe
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 23 Mar 2017 10:40:49 +0000 (13:40 +0300)
committerJacek Anaszewski <jacek.anaszewski@gmail.com>
Thu, 23 Mar 2017 19:23:57 +0000 (20:23 +0100)
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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
drivers/leds/leds-mt6323.c

index 48081bccbea51dbe0c275989ccd28f6d377d55be..8893c74e9a1f24c8f361553c9c1d33fc0b3104a2 100644 (file)
@@ -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;