]>
Commit | Line | Data |
---|---|---|
f601ab3a SL |
1 | From 48142bcd0c0163698860aa1ce7854580c4a62da8 Mon Sep 17 00:00:00 2001 |
2 | From: Kangjie Lu <kjlu@umn.edu> | |
3 | Date: Tue, 25 Dec 2018 22:18:23 -0600 | |
4 | Subject: leds: lp5523: fix a missing check of return value of lp55xx_read | |
5 | ||
6 | [ Upstream commit 248b57015f35c94d4eae2fdd8c6febf5cd703900 ] | |
7 | ||
8 | When lp55xx_read() fails, "status" is an uninitialized variable and thus | |
9 | may contain random value; using it leads to undefined behaviors. | |
10 | ||
11 | The fix inserts a check for the return value of lp55xx_read: if it | |
12 | fails, returns with its error code. | |
13 | ||
14 | Signed-off-by: Kangjie Lu <kjlu@umn.edu> | |
15 | Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com> | |
16 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
17 | --- | |
18 | drivers/leds/leds-lp5523.c | 4 +++- | |
19 | 1 file changed, 3 insertions(+), 1 deletion(-) | |
20 | ||
21 | diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c | |
22 | index 1d0187f42941a..d12370352ae34 100644 | |
23 | --- a/drivers/leds/leds-lp5523.c | |
24 | +++ b/drivers/leds/leds-lp5523.c | |
25 | @@ -318,7 +318,9 @@ static int lp5523_init_program_engine(struct lp55xx_chip *chip) | |
26 | ||
27 | /* Let the programs run for couple of ms and check the engine status */ | |
28 | usleep_range(3000, 6000); | |
29 | - lp55xx_read(chip, LP5523_REG_STATUS, &status); | |
30 | + ret = lp55xx_read(chip, LP5523_REG_STATUS, &status); | |
31 | + if (ret) | |
32 | + return ret; | |
33 | status &= LP5523_ENG_STATUS_MASK; | |
34 | ||
35 | if (status != LP5523_ENG_STATUS_MASK) { | |
36 | -- | |
37 | 2.19.1 | |
38 |