Takashi Iwai 8ada8f
From 6647f7a06eb030a2384ec71f0bb2e78854afabfe Mon Sep 17 00:00:00 2001
Takashi Iwai 8ada8f
From: Phillip Potter <phil@philpotter.co.uk>
Takashi Iwai 8ada8f
Date: Mon, 3 May 2021 13:56:36 +0200
Takashi Iwai 8ada8f
Subject: [PATCH] leds: lp5523: check return value of lp5xx_read and jump to cleanup code
Takashi Iwai 8ada8f
Git-commit: 6647f7a06eb030a2384ec71f0bb2e78854afabfe
Takashi Iwai 8ada8f
Patch-mainline: v5.13-rc3
Takashi Iwai 8ada8f
References: git-fixes
Takashi Iwai 8ada8f
Takashi Iwai 8ada8f
Check return value of lp5xx_read and if non-zero, jump to code at end of
Takashi Iwai 8ada8f
the function, causing lp5523_stop_all_engines to be executed before
Takashi Iwai 8ada8f
returning the error value up the call chain. This fixes the original
Takashi Iwai 8ada8f
commit (248b57015f35) which was reverted due to the University of Minnesota
Takashi Iwai 8ada8f
problems.
Takashi Iwai 8ada8f
Takashi Iwai 8ada8f
Cc: stable <stable@vger.kernel.org>
Takashi Iwai 8ada8f
Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Takashi Iwai 8ada8f
Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
Takashi Iwai 8ada8f
Link: https://lore.kernel.org/r/20210503115736.2104747-10-gregkh@linuxfoundation.org
Takashi Iwai 8ada8f
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Takashi Iwai 8ada8f
Acked-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai 8ada8f
Takashi Iwai 8ada8f
---
Takashi Iwai 8ada8f
 drivers/leds/leds-lp5523.c | 4 +++-
Takashi Iwai 8ada8f
 1 file changed, 3 insertions(+), 1 deletion(-)
Takashi Iwai 8ada8f
Takashi Iwai 8ada8f
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
Takashi Iwai 8ada8f
index 5036d7d5f3d4..b1590cb4a188 100644
Takashi Iwai 8ada8f
--- a/drivers/leds/leds-lp5523.c
Takashi Iwai 8ada8f
+++ b/drivers/leds/leds-lp5523.c
Takashi Iwai 8ada8f
@@ -305,7 +305,9 @@ static int lp5523_init_program_engine(struct lp55xx_chip *chip)
Takashi Iwai 8ada8f
 
Takashi Iwai 8ada8f
 	/* Let the programs run for couple of ms and check the engine status */
Takashi Iwai 8ada8f
 	usleep_range(3000, 6000);
Takashi Iwai 8ada8f
-	lp55xx_read(chip, LP5523_REG_STATUS, &status);
Takashi Iwai 8ada8f
+	ret = lp55xx_read(chip, LP5523_REG_STATUS, &status);
Takashi Iwai 8ada8f
+	if (ret)
Takashi Iwai 8ada8f
+		goto out;
Takashi Iwai 8ada8f
 	status &= LP5523_ENG_STATUS_MASK;
Takashi Iwai 8ada8f
 
Takashi Iwai 8ada8f
 	if (status != LP5523_ENG_STATUS_MASK) {
Takashi Iwai 8ada8f
-- 
Takashi Iwai 8ada8f
2.26.2
Takashi Iwai 8ada8f