nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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