]> git.proxmox.com Git - efi-boot-shim.git/commitdiff
shim: fix resource leak on should_use_fallback() error path
authorPeter Jones <pjones@redhat.com>
Tue, 17 Nov 2015 16:40:23 +0000 (11:40 -0500)
committerPeter Jones <pjones@redhat.com>
Tue, 17 Nov 2015 16:40:23 +0000 (11:40 -0500)
ExitBootServices() and Exit() should both clean these up anyway, but we
should do the right thing nonetheless.

Signed-off-by: Peter Jones <pjones@redhat.com>
shim.c

diff --git a/shim.c b/shim.c
index 305aaf31d91026b4e0eb3455ead7eea566ae4a34..d64d15bed870428297863b23d51390e0161d19f2 100644 (file)
--- a/shim.c
+++ b/shim.c
@@ -1270,8 +1270,8 @@ should_use_fallback(EFI_HANDLE image_handle)
        unsigned int pathlen = 0;
        CHAR16 *bootpath = NULL;
        EFI_FILE_IO_INTERFACE *fio = NULL;
-       EFI_FILE *vh;
-       EFI_FILE *fh;
+       EFI_FILE *vh = NULL;
+       EFI_FILE *fh = NULL;
        EFI_STATUS rc;
        int ret = 0;
 
@@ -1322,11 +1322,13 @@ should_use_fallback(EFI_HANDLE image_handle)
                uefi_call_wrapper(vh->Close, 1, vh);
                goto error;
        }
-       uefi_call_wrapper(fh->Close, 1, fh);
-       uefi_call_wrapper(vh->Close, 1, vh);
 
        ret = 1;
 error:
+       if (fh)
+               uefi_call_wrapper(fh->Close, 1, fh);
+       if (vh)
+           uefi_call_wrapper(vh->Close, 1, vh);
        if (bootpath)
                FreePool(bootpath);