Skip to contentSkip to conversation

leds: netxbig: off by one in netxbig_leds_get_of_pdata()

PATCH Applied Dan Carpenter 1 participant 1 message Apr 9, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 leds: netxbig: off by one in netxbig_leds_get_of_pdata()

The mode_val[] array has NETXBIG_LED_MODE_NUM (5) elements so the ">" here should be ">=".

drivers/leds/leds-netxbig.c +1 -1
index 028686f2..d0b743c 100644
@@ -512,7 +512,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
 						   "mode-val", 2 * i, &mode);
 			of_property_read_u32_index(child,
 						   "mode-val", 2 * i + 1, &val);
-			if (mode > NETXBIG_LED_MODE_NUM)
+			if (mode >= NETXBIG_LED_MODE_NUM)
 				return -EINVAL;
 			mode_val[mode] = val;
 		}