From e1e086d1f72c69d7e123037c2ec6301849c5ec7b Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Thu, 13 Jan 2022 13:41:57 +0100 Subject: [PATCH] boot: Use _cleanup_ in shim Also, better be safe than sorry and check the return value. --- src/boot/efi/shim.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/boot/efi/shim.c b/src/boot/efi/shim.c index fd9c489478d..fb4aecaee02 100644 --- a/src/boot/efi/shim.c +++ b/src/boot/efi/shim.c @@ -105,7 +105,6 @@ static EFIAPI EFI_STATUS security_policy_authentication (const EFI_SECURITY_PROT _cleanup_freepool_ EFI_DEVICE_PATH *dev_path = NULL; _cleanup_freepool_ CHAR16 *dev_path_str = NULL; EFI_HANDLE h; - EFI_FILE *root; _cleanup_freepool_ CHAR8 *file_buffer = NULL; UINTN file_size; @@ -123,8 +122,10 @@ static EFIAPI EFI_STATUS security_policy_authentication (const EFI_SECURITY_PROT if (EFI_ERROR(status)) return status; - /* No need to check return value, this already happened in efi_main() */ - root = LibOpenRoot(h); + _cleanup_(file_closep) EFI_FILE *root = LibOpenRoot(h); + if (!root) + return EFI_NOT_FOUND; + dev_path_str = DevicePathToStr(dp); if (!dev_path_str) return EFI_OUT_OF_RESOURCES; @@ -132,7 +133,6 @@ static EFIAPI EFI_STATUS security_policy_authentication (const EFI_SECURITY_PROT status = file_read(root, dev_path_str, 0, 0, &file_buffer, &file_size); if (EFI_ERROR(status)) return status; - root->Close(root); if (shim_validate(file_buffer, file_size)) return EFI_SUCCESS;