linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jack Stone <jwjstone@fastmail.fm>
To: tim.gardner@canonical.com
Cc: linux-fbdev@vger.kernel.org, lethal@linux-sh.org,
	linux-kernel@vger.kernel.org, Andy Whitcroft <apw@canonical.com>,
	Leann Ogasawara <leann.ogasawara@canonical.com>
Subject: Re: [PATCH] fbcon -- fix race between open and removal of framebuffers
Date: Thu, 05 May 2011 21:00:42 +0000	[thread overview]
Message-ID: <4DC30FFA.9030708@fastmail.fm> (raw)
In-Reply-To: <1304617307-7389-2-git-send-email-tim.gardner@canonical.com>

On 05/05/2011 18:41, tim.gardner@canonical.com wrote:
> +static struct fb_info *get_framebuffer_info(int idx)
> +__acquires(&registered_lock)
> +__releases(&registered_lock)
> +{
> +	struct fb_info *fb_info;
> +
> +	spin_lock(&registered_lock);
> +	fb_info = registered_fb[idx];
> +	fb_info->ref_count++;
> +	spin_unlock(&registered_lock);
> +
> +	return fb_info;
> +}
> +
>  static int
>  fb_open(struct inode *inode, struct file *file)
>  __acquires(&info->lock)
> @@ -1363,13 +1421,17 @@ __releases(&info->lock)
>  
>  	if (fbidx >= FB_MAX)
>  		return -ENODEV;
> -	info = registered_fb[fbidx];
> +	info = get_framebuffer_info(fbidx);
>  	if (!info)
>  		request_module("fb%d", fbidx);
> -	info = registered_fb[fbidx];
> +	info = get_framebuffer_info(fbidx);
>  	if (!info)
>  		return -ENODEV;

If the first get_framebuffer_info succeeds don't you up the ref count
twice? Shouldn't this be:

info = get_framebuffer_info(fbidx);
if (!info) {
	request_module("fb%d", fbidx);
	info = get_framebuffer_info(fbidx);
}
if (!info)
	return -ENODEV;

Thanks,

Jack

  parent reply	other threads:[~2011-05-05 21:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-05 17:41 [PATCH 0/1] fbcon -- fix race between open and removal of framebuffers tim.gardner
2011-05-05 17:41 ` [PATCH] " tim.gardner
2011-05-05 18:30   ` [PATCH] fbcon -- fix race between open and removal of Bruno Prémont
2011-05-05 21:00   ` Jack Stone [this message]
2011-05-06  1:09     ` [PATCH] fbcon -- fix race between open and removal of framebuffers Anca Emanuel
2011-05-06  1:44       ` [PATCH] fbcon -- fix race between open and removal of Greg KH
2011-05-10 12:47     ` [PATCH V2] fbcon -- fix race between open and removal of framebuffers Tim Gardner
2011-05-10 21:06       ` Jack Stone
2011-05-10 21:08         ` Jack Stone
2011-05-06  0:21   ` [PATCH] " Anca Emanuel
2011-05-10 13:52 ` [PATCH V3] " Tim Gardner
2011-05-10 21:44   ` [PATCH V3] fbcon -- fix race between open and removal of Bruno Prémont
2011-05-11 14:09     ` [PATCH V3] fbcon -- fix race between open and removal of framebuffers Tim Gardner
2011-05-11 14:27       ` [PATCH V3] fbcon -- fix race between open and removal of Bruno Prémont

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=4DC30FFA.9030708@fastmail.fm \
    --to=jwjstone@fastmail.fm \
    --cc=apw@canonical.com \
    --cc=leann.ogasawara@canonical.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tim.gardner@canonical.com \
    /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).