Skip to content

Commit

Permalink
Further fbcon sanity checking
Browse files Browse the repository at this point in the history
This moves the

    if (num_registered_fb == FB_MAX)
            return -ENXIO;

check _AFTER_ the call to do_remove_conflicting_framebuffers() as this
would (now in a safe way) allow a native driver to replace the
conflicting one even if all slots in registered_fb[] are taken.

This also prevents unregistering a framebuffer that is no longer
registered (vga16f will unregister at module unload time even if the
frame buffer had been unregistered earlier due to being found
conflicting).

Signed-off-by: Bruno Prémont <bonbons@linux-vserver.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Bruno Prémont authored and Linus Torvalds committed May 14, 2011
1 parent 712f314 commit c590cec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/video/fbmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1573,15 +1573,15 @@ static int do_register_framebuffer(struct fb_info *fb_info)
struct fb_event event;
struct fb_videomode mode;

if (num_registered_fb == FB_MAX)
return -ENXIO;

if (fb_check_foreignness(fb_info))
return -ENOSYS;

do_remove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id,
fb_is_primary_device(fb_info));

if (num_registered_fb == FB_MAX)
return -ENXIO;

num_registered_fb++;
for (i = 0 ; i < FB_MAX; i++)
if (!registered_fb[i])
Expand Down Expand Up @@ -1639,7 +1639,7 @@ static int do_unregister_framebuffer(struct fb_info *fb_info)
int i, ret = 0;

i = fb_info->node;
if (!registered_fb[i])
if (i < 0 || i >= FB_MAX || registered_fb[i] != fb_info)
return -EINVAL;

if (!lock_fb_info(fb_info))
Expand Down

0 comments on commit c590cec

Please sign in to comment.