Blame SOURCES/0388-net-net-Fix-possible-dereference-to-of-a-NULL-pointe.patch

9723a8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
9723a8
From: Darren Kenny <darren.kenny@oracle.com>
9723a8
Date: Fri, 27 Nov 2020 15:10:26 +0000
9723a8
Subject: [PATCH] net/net: Fix possible dereference to of a NULL pointer
9723a8
9723a8
It is always possible that grub_zalloc() could fail, so we should check for
9723a8
a NULL return. Otherwise we run the risk of dereferencing a NULL pointer.
9723a8
9723a8
Fixes: CID 296221
9723a8
9723a8
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
9723a8
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9723a8
---
9723a8
 grub-core/net/net.c | 9 +++++++--
9723a8
 1 file changed, 7 insertions(+), 2 deletions(-)
9723a8
9723a8
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
3efed6
index 1fd104aeaf2..a27c53eee1c 100644
9723a8
--- a/grub-core/net/net.c
9723a8
+++ b/grub-core/net/net.c
9723a8
@@ -89,8 +89,13 @@ grub_net_link_layer_add_address (struct grub_net_card *card,
9723a8
 
9723a8
   /* Add sender to cache table.  */
9723a8
   if (card->link_layer_table == NULL)
9723a8
-    card->link_layer_table = grub_zalloc (LINK_LAYER_CACHE_SIZE
9723a8
-					  * sizeof (card->link_layer_table[0]));
9723a8
+    {
9723a8
+      card->link_layer_table = grub_zalloc (LINK_LAYER_CACHE_SIZE
9723a8
+					    * sizeof (card->link_layer_table[0]));
9723a8
+      if (card->link_layer_table == NULL)
9723a8
+	return;
9723a8
+    }
9723a8
+
9723a8
   entry = &(card->link_layer_table[card->new_ll_entry]);
9723a8
   entry->avail = 1;
9723a8
   grub_memcpy (&entry->ll_address, ll, sizeof (entry->ll_address));