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

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