nalika / rpms / grub2

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