diff options
author | Andy Whitcroft <apw@canonical.com> | 2010-07-29 16:48:20 +0100 |
---|---|---|
committer | John Rigby <john.rigby@linaro.org> | 2011-03-16 15:48:57 -0600 |
commit | 3eebe58a5ae5cf46f0ca11e7ce854982187b36c5 (patch) | |
tree | edbc27eff2a8e5c514b5185c67ac9cc96dd2742d /include/linux | |
parent | 273fb700dab7e8c2375668685c4dedb7f8dab93c (diff) |
UBUNTU: SAUCE: fbcon -- fix race between open and removal of framebuffers
Currently there is no locking for updates to the registered_fb list.
This allows an open through /dev/fbN to pick up a registered framebuffer
pointer in parallel with it being released, as happens when a conflicting
framebuffer is ejected or on module unload. There is also no reference
counting on the framebuffer descriptor which is referenced from all open
files, leading to references to released or reused memory to persist on
these open files.
This patch adds a reference count to the framebuffer descriptor to prevent
it from being released until after all pending opens are closed. This
allows the pending opens to detect the closed status and unmap themselves.
It also adds locking to the framebuffer lookup path, locking it against
the removal path such that it is possible to atomically lookup and take a
reference to the descriptor. It also adds locking to the read and write
paths which currently could access the framebuffer descriptor after it
has been freed. Finally it moves the device to FBINFO_STATE_REMOVED to
indicate that all access should be errored for this device.
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Leann Ogasawara <leann.ogasawara@canonical.com>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/fb.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/fb.h b/include/linux/fb.h index 68ba85a00c06..1e8b785a4a64 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -832,6 +832,7 @@ struct fb_tile_ops { struct fb_info { int node; int flags; + int ref_count; struct mutex lock; /* Lock for open/release/ioctl funcs */ struct mutex mm_lock; /* Lock for fb_mmap and smem_* fields */ struct fb_var_screeninfo var; /* Current var */ @@ -871,6 +872,7 @@ struct fb_info { void *pseudo_palette; /* Fake palette of 16 colors */ #define FBINFO_STATE_RUNNING 0 #define FBINFO_STATE_SUSPENDED 1 +#define FBINFO_STATE_REMOVED 2 u32 state; /* Hardware state i.e suspend */ void *fbcon_par; /* fbcon use-only private area */ /* From here on everything is device dependent */ |