Commit 3c5193c9 authored by Kangjie Lu's avatar Kangjie Lu Committed by Kleber Sacilotto de Souza

leds: lp5523: fix a missing check of return value of lp55xx_read

BugLink: https://bugs.launchpad.net/bugs/1822271

[ Upstream commit 248b5701 ]

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: default avatarKangjie Lu <kjlu@umn.edu>
Signed-off-by: default avatarJacek Anaszewski <jacek.anaszewski@gmail.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarJuerg Haefliger <juerg.haefliger@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 8729272d
...@@ -318,7 +318,9 @@ static int lp5523_init_program_engine(struct lp55xx_chip *chip) ...@@ -318,7 +318,9 @@ static int lp5523_init_program_engine(struct lp55xx_chip *chip)
/* Let the programs run for couple of ms and check the engine status */ /* Let the programs run for couple of ms and check the engine status */
usleep_range(3000, 6000); usleep_range(3000, 6000);
lp55xx_read(chip, LP5523_REG_STATUS, &status); ret = lp55xx_read(chip, LP5523_REG_STATUS, &status);
if (ret)
return ret;
status &= LP5523_ENG_STATUS_MASK; status &= LP5523_ENG_STATUS_MASK;
if (status != LP5523_ENG_STATUS_MASK) { if (status != LP5523_ENG_STATUS_MASK) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment