Skip to content

Commit edf79dd

Browse files
committed
fbcon: Fix error paths in set_con2fb_map
This is a regressoin introduced in b07db39 ("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 <[email protected]> Reviewed-by: Javier Martinez Canillas <[email protected]> Acked-by: Helge Deller <[email protected]> Tested-by: Xingyuan Mo <[email protected]> Fixes: b07db39 ("fbcon: Ditch error handling for con2fb_release_oldinfo") Cc: Thomas Zimmermann <[email protected]> Cc: Sam Ravnborg <[email protected]> Cc: Xingyuan Mo <[email protected]> Cc: Thomas Zimmermann <[email protected]> Cc: Helge Deller <[email protected]> Cc: <[email protected]> # v5.19+
1 parent a552b73 commit edf79dd

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

drivers/video/fbdev/core/fbcon.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ static int set_con2fb_map(int unit, int newidx, int user)
823823
int oldidx = con2fb_map[unit];
824824
struct fb_info *info = fbcon_registered_fb[newidx];
825825
struct fb_info *oldinfo = NULL;
826-
int found, err = 0, show_logo;
826+
int err = 0, show_logo;
827827

828828
WARN_CONSOLE_UNLOCKED();
829829

@@ -841,26 +841,25 @@ static int set_con2fb_map(int unit, int newidx, int user)
841841
if (oldidx != -1)
842842
oldinfo = fbcon_registered_fb[oldidx];
843843

844-
found = search_fb_in_map(newidx);
845-
846-
if (!err && !found) {
844+
if (!search_fb_in_map(newidx)) {
847845
err = con2fb_acquire_newinfo(vc, info, unit);
848-
if (!err)
849-
con2fb_map[unit] = newidx;
846+
if (err)
847+
return err;
848+
849+
con2fb_map[unit] = newidx;
850+
fbcon_add_cursor_work(info);
850851
}
851852

852853
/*
853854
* If old fb is not mapped to any of the consoles,
854855
* fbcon should release it.
855856
*/
856-
if (!err && oldinfo && !search_fb_in_map(oldidx))
857+
if (oldinfo && !search_fb_in_map(oldidx))
857858
con2fb_release_oldinfo(vc, oldinfo, info);
858859

859860
show_logo = (fg_console == 0 && !user &&
860861
logo_shown != FBCON_LOGO_DONTSHOW);
861862

862-
if (!found)
863-
fbcon_add_cursor_work(info);
864863
con2fb_map_boot[unit] = newidx;
865864
con2fb_init_display(vc, info, unit, show_logo);
866865

0 commit comments

Comments
 (0)