* [RFC] fbmem: reset file->private_data on failed fb_open()
@ 2011-06-09 3:06 Wu Fengguang
2011-06-09 6:10 ` Bruno Prémont
0 siblings, 1 reply; 3+ messages in thread
From: Wu Fengguang @ 2011-06-09 3:06 UTC (permalink / raw)
To: Antonino A. Daplas; +Cc: Andrew Morton, linux-fbdev, LKML
I wrote this when looking at NULL dereference bug
https://bugzilla.kernel.org/show_bug.cgi?id\x18912
Will it help by clearing private_data? I have no idea at all, because
for regular files, ->release won't be called on failed ->open. Just in
case there are some exceptions in fbmem...
---
drivers/video/fbmem.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- linux-next.orig/drivers/video/fbmem.c 2011-06-09 10:36:06.000000000 +0800
+++ linux-next/drivers/video/fbmem.c 2011-06-09 10:39:30.000000000 +0800
@@ -1424,26 +1424,28 @@ __releases(&info->lock)
file->private_data = info;
if (info->fbops->fb_open) {
res = info->fbops->fb_open(info,1);
if (res)
module_put(info->fbops->owner);
}
#ifdef CONFIG_FB_DEFERRED_IO
if (info->fbdefio)
fb_deferred_io_open(info, inode, file);
#endif
out:
mutex_unlock(&info->lock);
- if (res)
+ if (res) {
+ file->private_data = NULL;
put_fb_info(info);
+ }
return res;
}
static int
fb_release(struct inode *inode, struct file *file)
__acquires(&info->lock)
__releases(&info->lock)
{
struct fb_info * const info = file->private_data;
mutex_lock(&info->lock);
if (info->fbops->fb_release)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] fbmem: reset file->private_data on failed fb_open()
2011-06-09 3:06 [RFC] fbmem: reset file->private_data on failed fb_open() Wu Fengguang
@ 2011-06-09 6:10 ` Bruno Prémont
2011-06-09 6:38 ` Wu Fengguang
0 siblings, 1 reply; 3+ messages in thread
From: Bruno Prémont @ 2011-06-09 6:10 UTC (permalink / raw)
To: Wu Fengguang; +Cc: Antonino A. Daplas, Andrew Morton, linux-fbdev, LKML
On Thu, 9 Jun 2011 11:06:28 Wu Fengguang <fengguang.wu@intel.com> wrote:
> I wrote this when looking at NULL dereference bug
> https://bugzilla.kernel.org/show_bug.cgi?id\x18912
The trace over there rather looks like closing of a framebuffer that
has been replaced (and destroyed) during boot sequence.
This action happens when switching from VESA to KMS from initrd
or early userspace boot sequence where plymouthd had already opened
vesafb.
That should hopefully be fixed by refcounting FBs as done during
2.6.39-rc7.
> Will it help by clearing private_data? I have no idea at all, because
> for regular files, ->release won't be called on failed ->open. Just in
> case there are some exceptions in fbmem...
fb devices files should be just as regular as any other device files...
> ---
> drivers/video/fbmem.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> --- linux-next.orig/drivers/video/fbmem.c 2011-06-09 10:36:06.000000000 +0800
> +++ linux-next/drivers/video/fbmem.c 2011-06-09 10:39:30.000000000 +0800
> @@ -1424,26 +1424,28 @@ __releases(&info->lock)
> file->private_data = info;
> if (info->fbops->fb_open) {
> res = info->fbops->fb_open(info,1);
> if (res)
> module_put(info->fbops->owner);
> }
> #ifdef CONFIG_FB_DEFERRED_IO
> if (info->fbdefio)
> fb_deferred_io_open(info, inode, file);
> #endif
> out:
> mutex_unlock(&info->lock);
> - if (res)
> + if (res) {
> + file->private_data = NULL;
> put_fb_info(info);
> + }
> return res;
> }
>
> static int
> fb_release(struct inode *inode, struct file *file)
> __acquires(&info->lock)
> __releases(&info->lock)
> {
> struct fb_info * const info = file->private_data;
>
> mutex_lock(&info->lock);
> if (info->fbops->fb_release)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] fbmem: reset file->private_data on failed fb_open()
2011-06-09 6:10 ` Bruno Prémont
@ 2011-06-09 6:38 ` Wu Fengguang
0 siblings, 0 replies; 3+ messages in thread
From: Wu Fengguang @ 2011-06-09 6:38 UTC (permalink / raw)
To: Bruno Prémont
Cc: Antonino A. Daplas, Andrew Morton, linux-fbdev@vger.kernel.org,
LKML, thomas.creutz
[Add CC to Thomas Creutz]
On Thu, Jun 09, 2011 at 02:10:19PM +0800, Bruno Prémont wrote:
> On Thu, 9 Jun 2011 11:06:28 Wu Fengguang <fengguang.wu@intel.com> wrote:
> > I wrote this when looking at NULL dereference bug
> > https://bugzilla.kernel.org/show_bug.cgi?id\x18912
>
> The trace over there rather looks like closing of a framebuffer that
> has been replaced (and destroyed) during boot sequence.
> This action happens when switching from VESA to KMS from initrd
> or early userspace boot sequence where plymouthd had already opened
> vesafb.
>
> That should hopefully be fixed by refcounting FBs as done during
> 2.6.39-rc7.
That's great! Then hopefully the bug can be closed?
> > Will it help by clearing private_data? I have no idea at all, because
> > for regular files, ->release won't be called on failed ->open. Just in
> > case there are some exceptions in fbmem...
>
> fb devices files should be just as regular as any other device files...
Good, thanks for the confirmation.
Thanks,
Fengguang
> > ---
> > drivers/video/fbmem.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > --- linux-next.orig/drivers/video/fbmem.c 2011-06-09 10:36:06.000000000 +0800
> > +++ linux-next/drivers/video/fbmem.c 2011-06-09 10:39:30.000000000 +0800
> > @@ -1424,26 +1424,28 @@ __releases(&info->lock)
> > file->private_data = info;
> > if (info->fbops->fb_open) {
> > res = info->fbops->fb_open(info,1);
> > if (res)
> > module_put(info->fbops->owner);
> > }
> > #ifdef CONFIG_FB_DEFERRED_IO
> > if (info->fbdefio)
> > fb_deferred_io_open(info, inode, file);
> > #endif
> > out:
> > mutex_unlock(&info->lock);
> > - if (res)
> > + if (res) {
> > + file->private_data = NULL;
> > put_fb_info(info);
> > + }
> > return res;
> > }
> >
> > static int
> > fb_release(struct inode *inode, struct file *file)
> > __acquires(&info->lock)
> > __releases(&info->lock)
> > {
> > struct fb_info * const info = file->private_data;
> >
> > mutex_lock(&info->lock);
> > if (info->fbops->fb_release)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-06-09 6:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-09 3:06 [RFC] fbmem: reset file->private_data on failed fb_open() Wu Fengguang
2011-06-09 6:10 ` Bruno Prémont
2011-06-09 6:38 ` Wu Fengguang
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).