summaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorKangjie Lu <kjlu@umn.edu>2018-12-25 22:18:23 -0600
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-02-27 10:08:05 +0100
commitcaa27a81df46e5a697ca6731677deeb45100883b (patch)
treed3d2393d8cbdba20f3ff2ebc7c1076aeb5392e83 /drivers/leds
parent733d1915bf571616746f563632015d3bf568bc87 (diff)
downloadlinux-stable-caa27a81df46e5a697ca6731677deeb45100883b.tar.gz
linux-stable-caa27a81df46e5a697ca6731677deeb45100883b.tar.bz2
linux-stable-caa27a81df46e5a697ca6731677deeb45100883b.zip
leds: lp5523: fix a missing check of return value of lp55xx_read
[ Upstream commit 248b57015f35c94d4eae2fdd8c6febf5cd703900 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-lp5523.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index 924e50aefb00..13838d72e297 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -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 */
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;
if (status != LP5523_ENG_STATUS_MASK) {