Skip to content

Commit 57d38f2

Browse files
npitregregkh
authored andcommitted
vt: fix unicode console freeing with a common interface
By directly using kfree() in different places we risk missing one if it is switched to using vfree(), especially if the corresponding vmalloc() is hidden away within a common abstraction. Oh wait, that's exactly what happened here. So let's fix this by creating a common abstraction for the free case as well. Signed-off-by: Nicolas Pitre <[email protected]> Reported-by: [email protected] Fixes: 9a98e7a ("vt: don't use kmalloc() for the unicode screen buffer") Cc: <[email protected]> Reviewed-by: Sam Ravnborg <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 092a9f5 commit 57d38f2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/tty/vt/vt.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,14 @@ static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows)
365365
return uniscr;
366366
}
367367

368+
static void vc_uniscr_free(struct uni_screen *uniscr)
369+
{
370+
vfree(uniscr);
371+
}
372+
368373
static void vc_uniscr_set(struct vc_data *vc, struct uni_screen *new_uniscr)
369374
{
370-
vfree(vc->vc_uni_screen);
375+
vc_uniscr_free(vc->vc_uni_screen);
371376
vc->vc_uni_screen = new_uniscr;
372377
}
373378

@@ -1230,7 +1235,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
12301235
err = resize_screen(vc, new_cols, new_rows, user);
12311236
if (err) {
12321237
kfree(newscreen);
1233-
kfree(new_uniscr);
1238+
vc_uniscr_free(new_uniscr);
12341239
return err;
12351240
}
12361241

0 commit comments

Comments
 (0)