linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: mc13xxx: fix a double-unlock issue
@ 2020-05-02 20:28 wu000273
  0 siblings, 0 replies; 2+ messages in thread
From: wu000273 @ 2020-05-02 20:28 UTC (permalink / raw)
  To: a.zummo; +Cc: alexandre.belloni, linux-rtc, linux-kernel, kjlu, wu000273

From: Qiushi Wu <wu000273@umn.edu>

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. To fix this problem, we
need to call mc13xxx_lock() again in this error path.

Signed-off-by: Qiushi Wu <wu000273@umn.edu>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread
* Re: [PATCH] rtc: mc13xxx: fix a double-unlock issue
@ 2020-05-03 12:05 Markus Elfring
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2020-05-03 12:05 UTC (permalink / raw)
  To: Qiushi Wu, linux-rtc
  Cc: kernel-janitors, linux-kernel, Alessandro Zummo,
	Alexandre Belloni, Kangjie Lu

> … To fix this problem,
> we need to call mc13xxx_lock() again in this error path.

How do you think about a wording variant like the following?

   Change description:
   …
   Thus add a call of the function “mc13xxx_lock” in an if branch
   for the completion of the exception handling.


Would you like to add the tag “Fixes”?

Regards,
Markus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-03 12:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-02 20:28 [PATCH] rtc: mc13xxx: fix a double-unlock issue wu000273
2020-05-03 12:05 Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).