linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fbmem: fix race condition between register_framebuffer() and fb_open()
@ 2011-05-24 19:54 Fabio Erculiani
  2011-05-24 20:45 ` [PATCH] fbmem: fix race condition between Bruno Prémont
  0 siblings, 1 reply; 14+ messages in thread
From: Fabio Erculiani @ 2011-05-24 19:54 UTC (permalink / raw)
  To: linux-fbdev; +Cc: lethal, linux-kernel, Fabio Erculiani

register_framebuffer() acquires registration_lock, then calls
do_register_framebuffer() which calls fb_notifier_call_chain()
which calls fb_open() which calls get_fb_info() which tries
(at last) to acquire registration_lock again.
This is a workaround.

Signed-off-by: Fabio Erculiani <lxnay@sabayon.org>
---
 drivers/video/fbmem.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 5aac00e..b9831a0 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1628,6 +1628,11 @@ static int do_register_framebuffer(struct fb_info *fb_info)
 	event.info = fb_info;
 	if (!lock_fb_info(fb_info))
 		return -ENODEV;
+
+	/* FIXME: unlock registration mutex before registration
+	 * notification is sent, in order to avoid deadlock.
+	 */
+	mutex_unlock(&registration_lock);
 	fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, &event);
 	unlock_fb_info(fb_info);
 	return 0;
@@ -1692,7 +1697,13 @@ register_framebuffer(struct fb_info *fb_info)
 
 	mutex_lock(&registration_lock);
 	ret = do_register_framebuffer(fb_info);
-	mutex_unlock(&registration_lock);
+	if (ret != 0)
+		/*
+		 * FIXME: mutex is unlocked only if ret = 0.
+		 * This is the second part of the workaround
+		 * that prevents deadlocking.
+		 */
+		mutex_unlock(&registration_lock);
 
 	return ret;
 }
-- 
1.7.5.rc1


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

end of thread, other threads:[~2011-05-25 19:16 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-24 19:54 [PATCH] fbmem: fix race condition between register_framebuffer() and fb_open() Fabio Erculiani
2011-05-24 20:45 ` [PATCH] fbmem: fix race condition between Bruno Prémont
2011-05-25 16:19   ` Bruno Prémont
2011-05-25 18:17     ` [PATCH] fbmem: fix race condition between register_framebuffer() Fabio Erculiani
2011-05-25 18:41       ` Anca Emanuel
2011-05-25 18:48         ` Fabio Erculiani
2011-05-25 18:51           ` [PATCH] fbmem: fix race condition between Bruno Prémont
2011-05-25 18:53             ` [PATCH] fbmem: fix race condition between register_framebuffer() Fabio Erculiani
2011-05-25 18:46       ` [PATCH] fbmem: fix race condition between Bruno Prémont
2011-05-25 18:52         ` [PATCH] fbmem: fix race condition between register_framebuffer() Fabio Erculiani
2011-05-25 18:57           ` [PATCH] fbmem: fix race condition between Bruno Prémont
2011-05-25 19:04             ` [PATCH] fbmem: fix race condition between register_framebuffer() Fabio Erculiani
2011-05-25 19:12               ` [PATCH] fbmem: fix race condition between Bruno Prémont
2011-05-25 19:16                 ` [PATCH] fbmem: fix race condition between register_framebuffer() Fabio Erculiani

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).