diff options
author | Kangjie Lu <kjlu@umn.edu> | 2018-12-25 23:18:23 -0500 |
---|---|---|
committer | Jacek Anaszewski <jacek.anaszewski@gmail.com> | 2019-01-17 16:27:39 -0500 |
commit | 248b57015f35c94d4eae2fdd8c6febf5cd703900 (patch) | |
tree | 880652e44f82321bb1c3130f2636b42ce80d2b2a | |
parent | bfeffd155283772bbe78c6a05dec7c0128ee500c (diff) |
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>
-rw-r--r-- | drivers/leds/leds-lp5523.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index a2e74feee2b2..fd64df5a57a5 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) | |||
318 | 318 | ||
319 | /* Let the programs run for couple of ms and check the engine status */ | 319 | /* Let the programs run for couple of ms and check the engine status */ |
320 | usleep_range(3000, 6000); | 320 | 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; | ||
322 | status &= LP5523_ENG_STATUS_MASK; | 324 | status &= LP5523_ENG_STATUS_MASK; |
323 | 325 | ||
324 | if (status != LP5523_ENG_STATUS_MASK) { | 326 | if (status != LP5523_ENG_STATUS_MASK) { |