aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBruno Prémont <bonbons@linux-vserver.org>2011-05-14 06:24:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-14 13:28:54 -0400
commitc590cece75728a85ea06801df3ebad2d7ad8612c (patch)
tree3f3f7ade41317d86305a3839d9f2ad646945aa60 /drivers
parent712f3147aee0fbbbbed2da20b21b272c5505125e (diff)
Further fbcon sanity checking
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/fbmem.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 46ee5e5a08c6..5aac00eb1830 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1573,15 +1573,15 @@ static int do_register_framebuffer(struct fb_info *fb_info)
1573 struct fb_event event; 1573 struct fb_event event;
1574 struct fb_videomode mode; 1574 struct fb_videomode mode;
1575 1575
1576 if (num_registered_fb == FB_MAX)
1577 return -ENXIO;
1578
1579 if (fb_check_foreignness(fb_info)) 1576 if (fb_check_foreignness(fb_info))
1580 return -ENOSYS; 1577 return -ENOSYS;
1581 1578
1582 do_remove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id, 1579 do_remove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id,
1583 fb_is_primary_device(fb_info)); 1580 fb_is_primary_device(fb_info));
1584 1581
1582 if (num_registered_fb == FB_MAX)
1583 return -ENXIO;
1584
1585 num_registered_fb++; 1585 num_registered_fb++;
1586 for (i = 0 ; i < FB_MAX; i++) 1586 for (i = 0 ; i < FB_MAX; i++)
1587 if (!registered_fb[i]) 1587 if (!registered_fb[i])
@@ -1639,7 +1639,7 @@ static int do_unregister_framebuffer(struct fb_info *fb_info)
1639 int i, ret = 0; 1639 int i, ret = 0;
1640 1640
1641 i = fb_info->node; 1641 i = fb_info->node;
1642 if (!registered_fb[i]) 1642 if (i < 0 || i >= FB_MAX || registered_fb[i] != fb_info)
1643 return -EINVAL; 1643 return -EINVAL;
1644 1644
1645 if (!lock_fb_info(fb_info)) 1645 if (!lock_fb_info(fb_info))