31004e
From 9435e9e0e5371624d0c3044e8ce7383b069717c3 Mon Sep 17 00:00:00 2001
31004e
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
31004e
Date: Sat, 13 Apr 2013 20:12:11 +0200
f74b50
Subject: [PATCH 300/482] 	Fix memory leaks in ofnet. 	Reported by:
31004e
 Francesco Lavra.
31004e
31004e
---
31004e
 ChangeLog                              | 5 +++++
31004e
 grub-core/net/drivers/ieee1275/ofnet.c | 8 ++++----
31004e
 2 files changed, 9 insertions(+), 4 deletions(-)
31004e
31004e
diff --git a/ChangeLog b/ChangeLog
31004e
index a965117..0514e73 100644
31004e
--- a/ChangeLog
31004e
+++ b/ChangeLog
31004e
@@ -1,3 +1,8 @@
31004e
+2013-04-13  Vladimir Serbinenko  <phcoder@gmail.com>
31004e
+
31004e
+	Fix memory leaks in ofnet.
31004e
+	Reported by: Francesco Lavra.
31004e
+
31004e
 2013-04-12  Vladimir Serbinenko  <phcoder@gmail.com>
31004e
 
31004e
 	* docs/man/grub-glue-efi.h2m: Add missing file.
31004e
diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c
31004e
index cd9b159..21b6214 100644
31004e
--- a/grub-core/net/drivers/ieee1275/ofnet.c
31004e
+++ b/grub-core/net/drivers/ieee1275/ofnet.c
31004e
@@ -97,10 +97,7 @@ get_card_packet (struct grub_net_card *dev)
31004e
 
31004e
   nb = grub_netbuff_alloc (dev->mtu + 64 + 2);
31004e
   if (!nb)
31004e
-    {
31004e
-      grub_netbuff_free (nb);
31004e
-      return NULL;
31004e
-    }
31004e
+    return NULL;
31004e
   /* Reserve 2 bytes so that 2 + 14/18 bytes of ethernet header is divisible
31004e
      by 4. So that IP header is aligned on 4 bytes. */
31004e
   grub_netbuff_reserve (nb, 2);
31004e
@@ -281,6 +278,9 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
31004e
     card->txbuf = grub_zalloc (card->txbufsize);
31004e
   if (!card->txbuf)
31004e
     {
31004e
+      grub_free (ofdata->path);
31004e
+      grub_free (ofdata);
31004e
+      grub_free (card);
31004e
       grub_print_error ();
31004e
       return 0;
31004e
     }
31004e
-- 
31004e
1.8.2.1
31004e