Skip to content

Commit 248b570

Browse files
kengiterjacek-anaszewski
authored andcommitted
leds: lp5523: fix a missing check of return value of lp55xx_read
When lp55xx_read() fails, "status" is an uninitialized variable and thus may contain random value; using it leads to undefined behaviors. The fix inserts a check for the return value of lp55xx_read: if it fails, returns with its error code. Signed-off-by: Kangjie Lu <kjlu@umn.edu> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
1 parent bfeffd1 commit 248b570

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/leds/leds-lp5523.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,9 @@ static int lp5523_init_program_engine(struct lp55xx_chip *chip)
318318

319319
/* Let the programs run for couple of ms and check the engine status */
320320
usleep_range(3000, 6000);
321-
lp55xx_read(chip, LP5523_REG_STATUS, &status);
321+
ret = lp55xx_read(chip, LP5523_REG_STATUS, &status);
322+
if (ret)
323+
return ret;
322324
status &= LP5523_ENG_STATUS_MASK;
323325

324326
if (status != LP5523_ENG_STATUS_MASK) {

0 commit comments

Comments
 (0)