From 70e8fb8d66703e5751ac4d3ad8efbfb0ffd8f29a Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Apr 20 2023 11:00:14 +0000 Subject: fbcon: Fix error paths in set_con2fb_map (bsc#1012628). --- diff --git a/patches.kernel.org/6.2.12-026-fbcon-Fix-error-paths-in-set_con2fb_map.patch b/patches.kernel.org/6.2.12-026-fbcon-Fix-error-paths-in-set_con2fb_map.patch new file mode 100644 index 0000000..b95b66a --- /dev/null +++ b/patches.kernel.org/6.2.12-026-fbcon-Fix-error-paths-in-set_con2fb_map.patch @@ -0,0 +1,101 @@ +From: Daniel Vetter +Date: Wed, 12 Apr 2023 17:23:49 +0200 +Subject: [PATCH] fbcon: Fix error paths in set_con2fb_map +References: bsc#1012628 +Patch-mainline: 6.2.12 +Git-commit: edf79dd2172233452ff142dcc98b19d955fc8974 + +commit edf79dd2172233452ff142dcc98b19d955fc8974 upstream. + +This is a regressoin introduced in b07db3958485 ("fbcon: Ditch error +handling for con2fb_release_oldinfo"). I failed to realize what the if +(!err) checks. The mentioned commit was dropping the +con2fb_release_oldinfo() return value but the if (!err) was also +checking whether the con2fb_acquire_newinfo() function call above +failed or not. + +Fix this with an early return statement. + +Note that there's still a difference compared to the orginal state of +the code, the below lines are now also skipped on error: + + if (!search_fb_in_map(info_idx)) + info_idx = newidx; + +These are only needed when we've actually thrown out an old fb_info +from the console mappings, which only happens later on. + +Also move the fbcon_add_cursor_work() call into the same if block, +it's all protected by console_lock so doesn't matter when we set up +the blinking cursor delayed work anyway. This further simplifies the +control flow and allows us to ditch the found local variable. + +v2: Clarify commit message (Javier) + +Signed-off-by: Daniel Vetter +Reviewed-by: Javier Martinez Canillas +Acked-by: Helge Deller +Tested-by: Xingyuan Mo +Fixes: b07db3958485 ("fbcon: Ditch error handling for con2fb_release_oldinfo") +Cc: Thomas Zimmermann +Cc: Sam Ravnborg +Cc: Xingyuan Mo +Cc: Thomas Zimmermann +Cc: Helge Deller +Cc: # v5.19+ +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Jiri Slaby +--- + drivers/video/fbdev/core/fbcon.c | 17 ++++++++--------- + 1 file changed, 8 insertions(+), 9 deletions(-) + +diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c +index 2bc8baa9..b9dc29d6 100644 +--- a/drivers/video/fbdev/core/fbcon.c ++++ b/drivers/video/fbdev/core/fbcon.c +@@ -823,7 +823,7 @@ static int set_con2fb_map(int unit, int newidx, int user) + int oldidx = con2fb_map[unit]; + struct fb_info *info = fbcon_registered_fb[newidx]; + struct fb_info *oldinfo = NULL; +- int found, err = 0, show_logo; ++ int err = 0, show_logo; + + WARN_CONSOLE_UNLOCKED(); + +@@ -841,26 +841,25 @@ static int set_con2fb_map(int unit, int newidx, int user) + if (oldidx != -1) + oldinfo = fbcon_registered_fb[oldidx]; + +- found = search_fb_in_map(newidx); +- +- if (!err && !found) { ++ if (!search_fb_in_map(newidx)) { + err = con2fb_acquire_newinfo(vc, info, unit); +- if (!err) +- con2fb_map[unit] = newidx; ++ if (err) ++ return err; ++ ++ con2fb_map[unit] = newidx; ++ fbcon_add_cursor_work(info); + } + + /* + * If old fb is not mapped to any of the consoles, + * fbcon should release it. + */ +- if (!err && oldinfo && !search_fb_in_map(oldidx)) ++ if (oldinfo && !search_fb_in_map(oldidx)) + con2fb_release_oldinfo(vc, oldinfo, info); + + show_logo = (fg_console == 0 && !user && + logo_shown != FBCON_LOGO_DONTSHOW); + +- if (!found) +- fbcon_add_cursor_work(info); + con2fb_map_boot[unit] = newidx; + con2fb_init_display(vc, info, unit, show_logo); + +-- +2.35.3 + diff --git a/series.conf b/series.conf index dcabfc4..1863c69 100644 --- a/series.conf +++ b/series.conf @@ -2253,6 +2253,7 @@ patches.kernel.org/6.2.12-023-mtd-rawnand-stm32_fmc2-remove-unsupported-EDO-.patch patches.kernel.org/6.2.12-024-mtd-rawnand-stm32_fmc2-use-timings.mode-instea.patch patches.kernel.org/6.2.12-025-KVM-arm64-PMU-Restore-the-guest-s-EL0-event-co.patch + patches.kernel.org/6.2.12-026-fbcon-Fix-error-paths-in-set_con2fb_map.patch ######################################################## # Build fixes that apply to the vanilla kernel too.