Skip to contentSkip to conversation

rtc: rv8803: unlock on error path in rv8803_set_time()

PATCH In review Dan Carpenter 2 participants 2 messages Jun 28, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: rv8803: unlock on error path in rv8803_set_time()

Call mutex_unlock(&rv8803->flags_lock) before returning if rv8803_regs_reset() fails.

Fixes f8176e0bb83f ("rtc: rv8803: initialize registers on post-probe voltage loss")
---
 drivers/rtc/rtc-rv8803.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/rtc/rtc-rv8803.c +3 -1
index fe1247e771b9..3527a0521e9b 100644
@@ -315,8 +315,10 @@ static int rv8803_set_time(struct device *dev, struct rtc_time *tm)
 
 	if (flags & RV8803_FLAG_V2F) {
 		ret = rv8803_regs_reset(rv8803);
-		if (ret)
+		if (ret) {
+			mutex_unlock(&rv8803->flags_lock);
 			return ret;
+		}
 	}
 
 	ret = rv8803_write_reg(rv8803->client, RV8803_FLAG,
Signature · 1 line
2.35.1
#1 lore raw

Hi Dan,

Quoted 8 lines · Dan Carpenter

Call mutex_unlock(&rv8803->flags_lock) before returning if rv8803_regs_reset() fails.

Fixes f8176e0bb83f ("rtc: rv8803: initialize registers on post-probe voltage loss")
---
 drivers/rtc/rtc-rv8803.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

A fix for this is already posted here:

https://lore.kernel.org/lkml/[email protected]/

Sascha

Quoted 21 lines
drivers/rtc/rtc-rv8803.c +3 -1
index fe1247e771b9..3527a0521e9b 100644
@@ -315,8 +315,10 @@ static int rv8803_set_time(struct device *dev, struct rtc_time *tm)
 
 	if (flags & RV8803_FLAG_V2F) {
 		ret = rv8803_regs_reset(rv8803);
-		if (ret)
+		if (ret) {
+			mutex_unlock(&rv8803->flags_lock);
 			return ret;
+		}
 	}
 
 	ret = rv8803_write_reg(rv8803->client, RV8803_FLAG,
Signature · 1 line
2.35.1
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |