Blame SOURCES/efibootmgr-0.5.4-make_boot_var-does-not-check-for-failed-status-with-.patch

8dd33d
From 5fcfccb39089febb89945b841f489b5acc7638ce Mon Sep 17 00:00:00 2001
8dd33d
From: Lane Winner <lane.winner@oracle.com>
8dd33d
Date: Tue, 24 Apr 2012 12:58:57 -0500
8dd33d
Subject: [PATCH 5/5] make_boot_var does not check for failed status with
8dd33d
 create_variable. This can result in a memory leak.
8dd33d
 Additionally the user should be notified of the
8dd33d
 problem.
8dd33d
8dd33d
We encounter this issue on one system after filling up the UEFI boot list
8dd33d
with dummy devices.
8dd33d
8dd33d
The patch fix the problem. It was verified on a Mensa system using RHEL 6.0
8dd33d
8dd33d
Signed-off-by: Yinghai Lu<yinghai@kernel.org>
8dd33d
---
8dd33d
 src/efibootmgr/efibootmgr.c | 8 +++++++-
8dd33d
 1 file changed, 7 insertions(+), 1 deletion(-)
8dd33d
8dd33d
diff --git a/src/efibootmgr/efibootmgr.c b/src/efibootmgr/efibootmgr.c
8dd33d
index de67af0..236365a 100644
8dd33d
--- a/src/efibootmgr/efibootmgr.c
8dd33d
+++ b/src/efibootmgr/efibootmgr.c
8dd33d
@@ -239,6 +239,7 @@ warn_duplicate_name(list_t *boot_list)
8dd33d
 static var_entry_t *
8dd33d
 make_boot_var(list_t *boot_list)
8dd33d
 {
8dd33d
+	efi_status_t status;
8dd33d
 	var_entry_t *boot;
8dd33d
 	int free_number;
8dd33d
 	list_t *pos;
8dd33d
@@ -271,7 +272,12 @@ make_boot_var(list_t *boot_list)
8dd33d
 		free(boot);
8dd33d
 		return NULL;
8dd33d
 	}
8dd33d
-	create_variable(&boot->var_data);
8dd33d
+
8dd33d
+	status = create_variable(&boot->var_data);
8dd33d
+	if (status != EFI_SUCCESS) {
8dd33d
+		free(boot);
8dd33d
+		return NULL;
8dd33d
+	}
8dd33d
 	list_add_tail(&boot->list, boot_list);
8dd33d
 	return boot;
8dd33d
 }
8dd33d
-- 
8dd33d
1.8.0
8dd33d