[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200116170509.12787-239-sashal@kernel.org>
Date: Thu, 16 Jan 2020 12:02:20 -0500
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc: Dan Carpenter <dan.carpenter@...cle.com>,
Tom Evans <tom.evans@...ec.com.au>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Sasha Levin <sashal@...nel.org>, linux-rtc@...r.kernel.org
Subject: [PATCH AUTOSEL 4.19 502/671] rtc: rv3029: revert error handling patch to rv3029_eeprom_write()
From: Dan Carpenter <dan.carpenter@...cle.com>
[ Upstream commit a6f26606ddd03c5eab8b2132f1bfaa768c06158f ]
My error handling "cleanup" was totally wrong. Both the "err" and "ret"
variables are required. The "err" variable holds the error codes for
rv3029_eeprom_enter/exit() and the "ret" variable holds the error codes
for if actual write fails. In my patch if the write failed, the
function probably still returned success.
Reported-by: Tom Evans <tom.evans@...ec.com.au>
Fixes: 97f5b0379c38 ("rtc: rv3029: Clean up error handling in rv3029_eeprom_write()")
Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>
Link: https://lore.kernel.org/r/20190817065604.GB29951@mwanda
Signed-off-by: Alexandre Belloni <alexandre.belloni@...tlin.com>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
drivers/rtc/rtc-rv3029c2.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/rtc/rtc-rv3029c2.c b/drivers/rtc/rtc-rv3029c2.c
index 3d6174eb32f6..cfe3aece51d1 100644
--- a/drivers/rtc/rtc-rv3029c2.c
+++ b/drivers/rtc/rtc-rv3029c2.c
@@ -282,13 +282,13 @@ static int rv3029_eeprom_read(struct device *dev, u8 reg,
static int rv3029_eeprom_write(struct device *dev, u8 reg,
u8 const buf[], size_t len)
{
- int ret;
+ int ret, err;
size_t i;
u8 tmp;
- ret = rv3029_eeprom_enter(dev);
- if (ret < 0)
- return ret;
+ err = rv3029_eeprom_enter(dev);
+ if (err < 0)
+ return err;
for (i = 0; i < len; i++, reg++) {
ret = rv3029_read_regs(dev, reg, &tmp, 1);
@@ -304,11 +304,11 @@ static int rv3029_eeprom_write(struct device *dev, u8 reg,
break;
}
- ret = rv3029_eeprom_exit(dev);
- if (ret < 0)
- return ret;
+ err = rv3029_eeprom_exit(dev);
+ if (err < 0)
+ return err;
- return 0;
+ return ret;
}
static int rv3029_eeprom_update_bits(struct device *dev,
--
2.20.1
Powered by blists - more mailing lists