Skip to content

Commit c590cec

Browse files
Bruno Prémonttorvalds
authored andcommitted
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>
1 parent 712f314 commit c590cec

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎drivers/video/fbmem.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,15 +1573,15 @@ static int do_register_framebuffer(struct fb_info *fb_info)
15731573
struct fb_event event;
15741574
struct fb_videomode mode;
15751575

1576-
if (num_registered_fb == FB_MAX)
1577-
return -ENXIO;
1578-
15791576
if (fb_check_foreignness(fb_info))
15801577
return -ENOSYS;
15811578

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

1582+
if (num_registered_fb == FB_MAX)
1583+
return -ENXIO;
1584+
15851585
num_registered_fb++;
15861586
for (i = 0 ; i < FB_MAX; i++)
15871587
if (!registered_fb[i])
@@ -1639,7 +1639,7 @@ static int do_unregister_framebuffer(struct fb_info *fb_info)
16391639
int i, ret = 0;
16401640

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

16451645
if (!lock_fb_info(fb_info))

0 commit comments

Comments
 (0)