]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-4.4/leds-lp5523-fix-a-missing-check-of-return-value-of-l.patch
drop perf-trace-support-multiple-vfs_getname-probes.patch from 4.4 and 4.9 queues
[thirdparty/kernel/stable-queue.git] / queue-4.4 / leds-lp5523-fix-a-missing-check-of-return-value-of-l.patch
CommitLineData
f601ab3a
SL
1From 48142bcd0c0163698860aa1ce7854580c4a62da8 Mon Sep 17 00:00:00 2001
2From: Kangjie Lu <kjlu@umn.edu>
3Date: Tue, 25 Dec 2018 22:18:23 -0600
4Subject: leds: lp5523: fix a missing check of return value of lp55xx_read
5
6[ Upstream commit 248b57015f35c94d4eae2fdd8c6febf5cd703900 ]
7
8When lp55xx_read() fails, "status" is an uninitialized variable and thus
9may contain random value; using it leads to undefined behaviors.
10
11The fix inserts a check for the return value of lp55xx_read: if it
12fails, returns with its error code.
13
14Signed-off-by: Kangjie Lu <kjlu@umn.edu>
15Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
16Signed-off-by: Sasha Levin <sashal@kernel.org>
17---
18 drivers/leds/leds-lp5523.c | 4 +++-
19 1 file changed, 3 insertions(+), 1 deletion(-)
20
21diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
22index 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--
372.19.1
38