summaryrefslogtreecommitdiffstats
path: root/consolemap-fix-memory-leaking-bug.patch
diff options
context:
space:
mode:
Diffstat (limited to 'consolemap-fix-memory-leaking-bug.patch')
-rw-r--r--consolemap-fix-memory-leaking-bug.patch37
1 files changed, 37 insertions, 0 deletions
diff --git a/consolemap-fix-memory-leaking-bug.patch b/consolemap-fix-memory-leaking-bug.patch
new file mode 100644
index 000000000..04d16049a
--- /dev/null
+++ b/consolemap-fix-memory-leaking-bug.patch
@@ -0,0 +1,37 @@
+From 84ecc2f6eb1cb12e6d44818f94fa49b50f06e6ac Mon Sep 17 00:00:00 2001
+From: Gen Zhang <blackgod016574@gmail.com>
+Date: Thu, 23 May 2019 08:34:52 +0800
+Subject: 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: Gen Zhang <blackgod016574@gmail.com>
+Reviewed-by: Kees Cook <keescook@chromium.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/tty/vt/consolemap.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c
+index b28aa0d289f8..79fcc96cc7c0 100644
+--- a/drivers/tty/vt/consolemap.c
++++ b/drivers/tty/vt/consolemap.c
+@@ -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) */
+ }
+
+--
+cgit 1.2-0.3.lf.el7
+