nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0235-efi-fix-memory-leak-in-variable-handling.patch

f725e3
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
f725e3
From: Ignat Korchagin <ignat@cloudflare.com>
f725e3
Date: Thu, 23 Jul 2015 21:13:09 +0300
f725e3
Subject: [PATCH] efi: fix memory leak in variable handling
f725e3
f725e3
---
f725e3
 grub-core/kern/efi/efi.c | 8 ++++++--
f725e3
 1 file changed, 6 insertions(+), 2 deletions(-)
f725e3
f725e3
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
f725e3
index 453f97a7595..0cd64cdb59e 100644
f725e3
--- a/grub-core/kern/efi/efi.c
f725e3
+++ b/grub-core/kern/efi/efi.c
f725e3
@@ -211,6 +211,7 @@ grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid,
f725e3
 			| GRUB_EFI_VARIABLE_BOOTSERVICE_ACCESS
f725e3
 			| GRUB_EFI_VARIABLE_RUNTIME_ACCESS),
f725e3
 		       datasize, data);
f725e3
+  grub_free (var16);
f725e3
   if (status == GRUB_EFI_SUCCESS)
f725e3
     return GRUB_ERR_NONE;
f725e3
 
f725e3
@@ -242,8 +243,11 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid,
f725e3
 
f725e3
   status = efi_call_5 (r->get_variable, var16, guid, NULL, &datasize, NULL);
f725e3
 
f725e3
-  if (!datasize)
f725e3
-    return NULL;
f725e3
+  if (status != GRUB_EFI_SUCCESS || !datasize)
f725e3
+    {
f725e3
+      grub_free (var16);
f725e3
+      return NULL;
f725e3
+    }
f725e3
 
f725e3
   data = grub_malloc (datasize);
f725e3
   if (!data)