• Daniel Vetter's avatar
    fbcon: Remove fbcon_has_exited · 1f4ed2fb
    Daniel Vetter authored
    This is unused code since
    
    commit 6104c370
    Author: Daniel Vetter <daniel.vetter@ffwll.ch>
    Date:   Tue Aug 1 17:32:07 2017 +0200
    
        fbcon: Make fbcon a built-time depency for fbdev
    
    when fbcon was made a compile-time static dependency of fbdev. We
    can't exit fbcon anymore without exiting fbdev first, which only works
    if all fbdev drivers have unloaded already. Hence this is all dead
    code.
    
    v2: I missed that fbcon_exit is also called from con_deinit stuff, and
    there fbcon_has_exited prevents double-cleanup. But we can fix that
    by properly resetting con2fb_map[] to all -1, which is used everywhere
    else to indicate "no fb_info allocate to this console". With that
    change the double-cleanup (which resulted in a module refcount underflow,
    among other things) is prevented.
    
    Aside: con2fb_map is a signed char, so don't register more than 128 fb_info
    or hilarity will ensue.
    
    v3: CI showed me that I still didn't fully understand what's going on
    here. The leaked references in con2fb_map have been used upon
    rebinding the fb console in fbcon_init. It worked because fbdev
    unregistering still cleaned out con2fb_map, and reset it to info_idx.
    If the last fbdev driver unregistered, then it also reset info_idx,
    and unregistered the fbcon driver.
    
    Imo that's all a bit fragile, so let's keep the con2fb_map reset to
    -1, and in fbcon_init pick info_idx if we're starting fresh. That
    means unbinding and rebinding will cleanse the mapping, but why are
    you doing that if you want to retain the mapping, so should be fine.
    
    Also, I think info_idx == -1 is impossible in fbcon_init - we
    unregister the fbcon in that case. So catch&warn about that.
    
    v4: Drop unecessary assignment - I forgot to delete the first
    assignment of info in fbcon_init.
    
    Cc: Sam Ravnborg <sam@ravnborg.org>
    Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
    Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
    Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
    Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
    Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
    Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
    Cc: Hans de Goede <hdegoede@redhat.com>
    Cc: "Noralf Trønnes" <noralf@tronnes.org>
    Cc: Yisheng Xie <ysxie@foxmail.com>
    Cc: Konstantin Khorenko <khorenko@virtuozzo.com>
    Cc: Prarit Bhargava <prarit@redhat.com>
    Cc: Kees Cook <keescook@chromium.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-10-daniel.vetter@ffwll.ch
    1f4ed2fb
fbcon.c 90.5 KB