Skip to content

Commit a6dbe44

Browse files
Nicolas Pitregregkh
authored andcommitted
vt: perform safe console erase in the right order
Commit 4b4ecd9 ("vt: Perform safe console erase only once") removed what appeared to be an extra call to scr_memsetw(). This missed the fact that set_origin() must be called before clearing the screen otherwise old screen content gets restored on the screen when using vgacon. Let's fix that by moving all the scrollback handling to flush_scrollback() where it logically belongs, and invoking it before the actual screen clearing in csi_J(), making the code simpler in the end. Reported-by: Matthew Whitehead <tedheadster@gmail.com> Signed-off-by: Nicolas Pitre <nico@linaro.org> Tested-by: Matthew Whitehead <tedheadster@gmail.com> Fixes: 4b4ecd9 ("vt: Perform safe console erase only once") Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c392ed4 commit a6dbe44

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

drivers/tty/vt/vt.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,11 @@ static void flush_scrollback(struct vc_data *vc)
935935
{
936936
WARN_CONSOLE_UNLOCKED();
937937

938+
set_origin(vc);
938939
if (vc->vc_sw->con_flush_scrollback)
939940
vc->vc_sw->con_flush_scrollback(vc);
941+
else
942+
vc->vc_sw->con_switch(vc);
940943
}
941944

942945
/*
@@ -1505,8 +1508,10 @@ static void csi_J(struct vc_data *vc, int vpar)
15051508
count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1;
15061509
start = (unsigned short *)vc->vc_origin;
15071510
break;
1511+
case 3: /* include scrollback */
1512+
flush_scrollback(vc);
1513+
/* fallthrough */
15081514
case 2: /* erase whole display */
1509-
case 3: /* (and scrollback buffer later) */
15101515
vc_uniscr_clear_lines(vc, 0, vc->vc_rows);
15111516
count = vc->vc_cols * vc->vc_rows;
15121517
start = (unsigned short *)vc->vc_origin;
@@ -1515,13 +1520,7 @@ static void csi_J(struct vc_data *vc, int vpar)
15151520
return;
15161521
}
15171522
scr_memsetw(start, vc->vc_video_erase_char, 2 * count);
1518-
if (vpar == 3) {
1519-
set_origin(vc);
1520-
flush_scrollback(vc);
1521-
if (con_is_visible(vc))
1522-
update_screen(vc);
1523-
} else if (con_should_update(vc))
1524-
do_update_region(vc, (unsigned long) start, count);
1523+
update_region(vc, (unsigned long) start, count);
15251524
vc->vc_need_wrap = 0;
15261525
}
15271526

0 commit comments

Comments
 (0)