arrfab / rpms / shim

Forked from rpms/shim 4 years ago
Clone

Blame SOURCES/0038-Free-the-string-from-DevicePathToStr.patch

4210fa
From c36d88cb16d10fdc8da2abcc00d3c51f0d425e34 Mon Sep 17 00:00:00 2001
4210fa
From: Gary Ching-Pang Lin <glin@suse.com>
4210fa
Date: Thu, 31 Oct 2013 17:54:46 +0800
4210fa
Subject: [PATCH 38/74] Free the string from DevicePathToStr
4210fa
4210fa
Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
4210fa
4210fa
Conflicts:
4210fa
	shim.c
4210fa
---
4210fa
 shim.c | 20 +++++++++++++-------
4210fa
 1 file changed, 13 insertions(+), 7 deletions(-)
4210fa
4210fa
diff --git a/shim.c b/shim.c
4210fa
index 69af766..72d6072 100644
4210fa
--- a/shim.c
4210fa
+++ b/shim.c
4210fa
@@ -1079,11 +1079,12 @@ should_use_fallback(EFI_HANDLE image_handle)
4210fa
 	EFI_GUID loaded_image_protocol = LOADED_IMAGE_PROTOCOL;
4210fa
 	EFI_LOADED_IMAGE *li;
4210fa
 	unsigned int pathlen = 0;
4210fa
-	CHAR16 *bootpath;
4210fa
+	CHAR16 *bootpath = NULL;
4210fa
 	EFI_FILE_IO_INTERFACE *fio = NULL;
4210fa
 	EFI_FILE *vh;
4210fa
 	EFI_FILE *fh;
4210fa
 	EFI_STATUS rc;
4210fa
+	int ret = 0;
4210fa
 
4210fa
 	rc = uefi_call_wrapper(BS->HandleProtocol, 3, image_handle,
4210fa
 				       &loaded_image_protocol, (void **)&li;;
4210fa
@@ -1101,23 +1102,23 @@ should_use_fallback(EFI_HANDLE image_handle)
4210fa
 	 */
4210fa
 	if (StrnCaseCmp(bootpath, L"\\EFI\\BOOT\\BOOT", 14) &&
4210fa
 			StrnCaseCmp(bootpath, L"\\EFI\\BOOT\\/BOOT", 15))
4210fa
-		return 0;
4210fa
+		goto error;
4210fa
 
4210fa
 	pathlen = StrLen(bootpath);
4210fa
 	if (pathlen < 5 || StrCaseCmp(bootpath + pathlen - 4, L".EFI"))
4210fa
-		return 0;
4210fa
+		goto error;
4210fa
 
4210fa
 	rc = uefi_call_wrapper(BS->HandleProtocol, 3, li->DeviceHandle,
4210fa
 			       &FileSystemProtocol, (void **)&fio;;
4210fa
 	if (EFI_ERROR(rc)) {
4210fa
 		perror(L"Could not get fio for li->DeviceHandle: %r\n", rc);
4210fa
-		return 0;
4210fa
+		goto error;
4210fa
 	}
4210fa
 
4210fa
 	rc = uefi_call_wrapper(fio->OpenVolume, 2, fio, &vh;;
4210fa
 	if (EFI_ERROR(rc)) {
4210fa
 		perror(L"Could not open fio volume: %r\n", rc);
4210fa
-		return 0;
4210fa
+		goto error;
4210fa
 	}
4210fa
 
4210fa
 	rc = uefi_call_wrapper(vh->Open, 5, vh, &fh, L"\\EFI\\BOOT" FALLBACK,
4210fa
@@ -1130,12 +1131,17 @@ should_use_fallback(EFI_HANDLE image_handle)
4210fa
 		 * 	 rc);
4210fa
 		 */
4210fa
 		uefi_call_wrapper(vh->Close, 1, vh);
4210fa
-		return 0;
4210fa
+		goto error;
4210fa
 	}
4210fa
 	uefi_call_wrapper(fh->Close, 1, fh);
4210fa
 	uefi_call_wrapper(vh->Close, 1, vh);
4210fa
 
4210fa
-	return 1;
4210fa
+	ret = 1;
4210fa
+error:
4210fa
+	if (bootpath)
4210fa
+		FreePool(bootpath);
4210fa
+
4210fa
+	return ret;
4210fa
 }
4210fa
 
4210fa
 /*
4210fa
-- 
4210fa
1.9.3
4210fa