Signed-off-by: Qiumiao Zhang <zhangqiumiao1@huawei.com> (cherry picked from commit c141a13130da5dca205b607533751a6ba6c9581e)
36 lines
1.0 KiB
Diff
36 lines
1.0 KiB
Diff
From 1c06ec900591d1fab6fbacf80dc010541d0a5ec8 Mon Sep 17 00:00:00 2001
|
|
From: Alec Brown <alec.r.brown@oracle.com>
|
|
Date: Wed, 22 Jan 2025 18:04:44 +0000
|
|
Subject: [PATCH 63/73] net: Check if returned pointer for allocated memory is
|
|
NULL
|
|
|
|
When using grub_malloc(), the function can fail if we are out of memory.
|
|
After allocating memory we should check if this function returned NULL
|
|
and handle this error if it did.
|
|
|
|
Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
|
|
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
---
|
|
grub-core/net/net.c | 5 +++++
|
|
1 file changed, 5 insertions(+)
|
|
|
|
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
|
|
index 1abdc097f..6ea33d1cd 100644
|
|
--- a/grub-core/net/net.c
|
|
+++ b/grub-core/net/net.c
|
|
@@ -227,6 +227,11 @@ grub_net_ipv6_get_slaac (struct grub_net_card *card,
|
|
}
|
|
|
|
slaac->name = grub_malloc (sz);
|
|
+ if (slaac->name == NULL)
|
|
+ {
|
|
+ grub_free (slaac);
|
|
+ return NULL;
|
|
+ }
|
|
ptr = grub_stpcpy (slaac->name, card->name);
|
|
if (grub_net_hwaddr_cmp (&card->default_address, hwaddr) != 0)
|
|
{
|
|
--
|
|
2.33.0
|
|
|