2020-05-03 18:26:45

by Qiushi Wu

[permalink] [raw]
Subject: [PATCH v2] rtc: mc13xxx: fix a double-unlock issue

From: Qiushi Wu <[email protected]>

In function mc13xxx_rtc_probe, the mc13xxx_unlock() is called
before rtc_register_device(). But in the error path of
rtc_register_device(), the mc13xxx_unlock() is called again,
which causes a double-unlock problem. Thus add a call of the
function “mc13xxx_lock” in an if branch for the completion
of the exception handling.

Fixes: e4ae7023e182a ("rtc: mc13xxx: set range")
Signed-off-by: Qiushi Wu <[email protected]>
---
drivers/rtc/rtc-mc13xxx.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c
index afce2c0b4bd6..d6802e6191cb 100644
--- a/drivers/rtc/rtc-mc13xxx.c
+++ b/drivers/rtc/rtc-mc13xxx.c
@@ -308,8 +308,10 @@ static int __init mc13xxx_rtc_probe(struct platform_device *pdev)
mc13xxx_unlock(mc13xxx);

ret = rtc_register_device(priv->rtc);
- if (ret)
+ if (ret) {
+ mc13xxx_lock(mc13xxx);
goto err_irq_request;
+ }

return 0;

--
2.17.1


2020-05-11 14:27:56

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH v2] rtc: mc13xxx: fix a double-unlock issue

On 03/05/2020 13:22:35-0500, [email protected] wrote:
> From: Qiushi Wu <[email protected]>
>
> In function mc13xxx_rtc_probe, the mc13xxx_unlock() is called
> before rtc_register_device(). But in the error path of
> rtc_register_device(), the mc13xxx_unlock() is called again,
> which causes a double-unlock problem. Thus add a call of the
> function “mc13xxx_lock” in an if branch for the completion
> of the exception handling.
>
> Fixes: e4ae7023e182a ("rtc: mc13xxx: set range")
> Signed-off-by: Qiushi Wu <[email protected]>
> ---
> drivers/rtc/rtc-mc13xxx.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
Applied, thanks.

--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com