linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Bruno Prémont" <bonbons@linux-vserver.org>
To: Fabio Erculiani <lxnay@sabayon.org>
Cc: linux-fbdev@vger.kernel.org, lethal@linux-sh.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fbmem: fix race condition between
Date: Tue, 24 May 2011 20:45:45 +0000	[thread overview]
Message-ID: <20110524224545.08c53b1d@neptune.home> (raw)
In-Reply-To: <1306266871-12464-1-git-send-email-lxnay@sabayon.org>

On Tue, 24 May 2011 Fabio Erculiani <lxnay@sabayon.org> wrote:
> 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.

What calls fb_open() instead of just calling fb_info->fbops->fb_open
when it is set?
In other words what kernel handler of fb_notifier chain does file-based
open of the framebuffer or is the event pushed out synchronously to
userspace?

> 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;
>  }

  reply	other threads:[~2011-05-24 20:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-24 19:54 [PATCH] fbmem: fix race condition between register_framebuffer() and fb_open() Fabio Erculiani
2011-05-24 20:45 ` Bruno Prémont [this message]
2011-05-25 16:19   ` [PATCH] fbmem: fix race condition between 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110524224545.08c53b1d@neptune.home \
    --to=bonbons@linux-vserver.org \
    --cc=lethal@linux-sh.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lxnay@sabayon.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).