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

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