Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 84ecc2f6 authored by Gen Zhang's avatar Gen Zhang Committed by Greg Kroah-Hartman
Browse files

consolemap: Fix a memory leaking bug in drivers/tty/vt/consolemap.c



In function con_insert_unipair(), when allocation for p2 and p1[n]
fails, ENOMEM is returned, but previously allocated p1 is not freed,
remains as leaking memory. Thus we should free p1 as well when this
allocation fails.

Signed-off-by: default avatarGen Zhang <blackgod016574@gmail.com>
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 06aaa3d0
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -489,7 +489,11 @@ con_insert_unipair(struct uni_pagedir *p, u_short unicode, u_short fontpos)
	p2 = p1[n = (unicode >> 6) & 0x1f];
	if (!p2) {
		p2 = p1[n] = kmalloc_array(64, sizeof(u16), GFP_KERNEL);
		if (!p2) return -ENOMEM;
		if (!p2) {
			kfree(p1);
			p->uni_pgdir[n] = NULL;
			return -ENOMEM;
		}
		memset(p2, 0xff, 64*sizeof(u16)); /* No glyphs for the characters (yet) */
	}