do_register_framebuffer() installs the framebuffer in registered_fb[], sets its reference count and registers it with fbcon. It then returns the result of fbcon_fb_registered() to the caller, so a failed console takeover is reported as a registration failure even though the framebuffer itself is fully registered. A driver can reject fbcon's internal fb_open() call, which makes the takeover fail. The driver then frees the fb_info because it was told that registration failed, leaving a dangling entry in registered_fb[] and triggering the reference-count warning in framebuffer_release(). Console takeover is auxiliary. Report success once the framebuffer is registered and leave the console unbound if the takeover failed. Fixes: 97b67986f145 ("fbcon: call fbcon_fb_(un)registered directly") Cc: stable@vger.kernel.org Co-developed-by: Bin Yu Signed-off-by: Bin Yu Co-developed-by: Cheng Wen Signed-off-by: Cheng Wen Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn> --- drivers/video/fbdev/core/fbmem.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index c8aa163b0ecf..2f6d6be673b4 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -535,7 +535,13 @@ static int do_register_framebuffer(struct fb_info *fb_info) } #endif - return fbcon_fb_registered(fb_info); + /* + * The framebuffer is registered now. A failed console takeover + * is not a registration failure; reporting it would make drivers + * free a live fb_info and leave registered_fb[] dangling. + */ + fbcon_fb_registered(fb_info); + return 0; } static void unbind_console(struct fb_info *fb_info) -- 2.34.1