leds: lm3697: Fix out-of-bound access
authorGabriel David <ultracoolguy@tutanota.com>
Fri, 2 Oct 2020 22:27:00 +0000 (18:27 -0400)
committerPavel Machek <pavel@ucw.cz>
Mon, 5 Oct 2020 18:36:09 +0000 (20:36 +0200)
commit98d278ca00bd8f62c8bc98bd9e65372d16eb6956
treee4928fce367f64d4143689b2a10190b331a14022
parent8fd8f94235c2c925d80b2316e0ab2bdd00af9bae
leds: lm3697: Fix out-of-bound access

If both LED banks aren't used in device tree, an out-of-bounds
condition in lm3697_init occurs because of the for loop assuming that
all the banks are used.  Fix it by adding a variable that contains the
number of used banks.

Signed-off-by: Gabriel David <ultracoolguy@tutanota.com>
[removed extra rename, minor tweaks]
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Cc: stable@kernel.org
drivers/leds/leds-lm3697.c