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

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