Blame SOURCES/0046-grub-core-term-serial.c-grub_serial_register-Fix-inv.patch

a85e8e
From db5ae694f5e18c847b0e0dbe9a3d2c95239a7d33 Mon Sep 17 00:00:00 2001
a85e8e
From: Vladimir Serbinenko <phcoder@gmail.com>
a85e8e
Date: Sun, 26 Jan 2014 02:36:05 +0100
a85e8e
Subject: [PATCH 046/260] * grub-core/term/serial.c (grub_serial_register): Fix
a85e8e
 invalid free. Ensure that pointers are inited to NULL and that pointers are
a85e8e
 not accessed after free.
a85e8e
a85e8e
---
a85e8e
 ChangeLog               | 5 +++++
a85e8e
 grub-core/term/serial.c | 8 ++++----
a85e8e
 2 files changed, 9 insertions(+), 4 deletions(-)
a85e8e
a85e8e
diff --git a/ChangeLog b/ChangeLog
a85e8e
index c93f11fbb..67b4d5c2a 100644
a85e8e
--- a/ChangeLog
a85e8e
+++ b/ChangeLog
a85e8e
@@ -1,3 +1,8 @@
a85e8e
+2014-01-26  Vladimir Serbinenko  <phcoder@gmail.com>
a85e8e
+
a85e8e
+	* grub-core/term/serial.c (grub_serial_register): Fix invalid free.
a85e8e
+	Ensure that pointers are inited to NULL and that pointers are not
a85e8e
+	accessed after free.
a85e8e
 
a85e8e
 2014-01-25  Andrey Borzenkov <arvidjaar@gmail.com>
a85e8e
 
a85e8e
diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c
a85e8e
index b581a763e..c9b5574ae 100644
a85e8e
--- a/grub-core/term/serial.c
a85e8e
+++ b/grub-core/term/serial.c
a85e8e
@@ -338,23 +338,23 @@ grub_serial_register (struct grub_serial_port *port)
a85e8e
       grub_free (indata);
a85e8e
       return grub_errno;
a85e8e
     }
a85e8e
-  
a85e8e
-  out = grub_malloc (sizeof (*out));
a85e8e
+
a85e8e
+  out = grub_zalloc (sizeof (*out));
a85e8e
   if (!out)
a85e8e
     {
a85e8e
-      grub_free (in);
a85e8e
       grub_free (indata);
a85e8e
       grub_free ((char *) in->name);
a85e8e
+      grub_free (in);
a85e8e
       return grub_errno;
a85e8e
     }
a85e8e
 
a85e8e
   outdata = grub_malloc (sizeof (*outdata));
a85e8e
   if (!outdata)
a85e8e
     {
a85e8e
-      grub_free (in);
a85e8e
       grub_free (indata);
a85e8e
       grub_free ((char *) in->name);
a85e8e
       grub_free (out);
a85e8e
+      grub_free (in);
a85e8e
       return grub_errno;
a85e8e
     }
a85e8e
 
a85e8e
-- 
a85e8e
2.13.0
a85e8e