diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 48a8199f7845..bfb728d92b74 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -917,10 +917,20 @@ static void set_cursor(struct vc_data *vc) hide_cursor(vc); } +static inline void dump_vc(const char *func, const struct vc_data *vc) +{ + pr_info("%s: num=%u cols=%u rows=%u size_row=%u origin=%lu visible_origin=%lu " + "screenbuf=%px screenbuf_size=%u pos=%lu\n", + func, vc->vc_num, vc->vc_cols, vc->vc_rows, vc->vc_size_row, vc->vc_origin, + vc->vc_visible_origin, vc->vc_screenbuf, vc->vc_screenbuf_size, vc->vc_pos); +} + static void set_origin(struct vc_data *vc) { WARN_CONSOLE_UNLOCKED(); + dump_vc(__func__, vc); + dump_stack(); if (!con_is_visible(vc) || !vc->vc_sw->con_set_origin || !vc->vc_sw->con_set_origin(vc)) @@ -928,6 +938,7 @@ static void set_origin(struct vc_data *vc) vc->vc_visible_origin = vc->vc_origin; vc->vc_scr_end = vc->vc_origin + vc->vc_screenbuf_size; vc->vc_pos = vc->vc_origin + vc->vc_size_row * vc->vc_y + 2 * vc->vc_x; + dump_vc(__func__, vc); } static void save_screen(struct vc_data *vc) @@ -1125,9 +1136,10 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ if (!*vc->vc_uni_pagedir_loc) con_set_default_unimap(vc); - vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_KERNEL); + vc->vc_screenbuf = vc->vc_screenbuf_size ? kzalloc(vc->vc_screenbuf_size, GFP_KERNEL) : NULL; if (!vc->vc_screenbuf) goto err_free; + dump_vc(__func__, vc); /* If no drivers have overridden us and the user didn't pass a boot option, default to displaying the cursor */ @@ -1212,7 +1224,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) return 0; - if (new_screen_size > KMALLOC_MAX_SIZE) + if (new_screen_size > KMALLOC_MAX_SIZE || !new_screen_size) return -EINVAL; newscreen = kzalloc(new_screen_size, GFP_USER); if (!newscreen) @@ -3393,7 +3405,7 @@ static int __init con_init(void) INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK); tty_port_init(&vc->port); visual_init(vc, currcons, 1); - vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT); + vc->vc_screenbuf = vc->vc_screenbuf_size ? kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT) : NULL; vc_init(vc, vc->vc_rows, vc->vc_cols, currcons || !vc->vc_sw->con_save_screen); }