efi_loader: efi_capsule_delete_file() NULL dereference
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Wed, 2 Jun 2021 17:28:22 +0000 (19:28 +0200)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Tue, 8 Jun 2021 22:16:39 +0000 (00:16 +0200)
If opening a file fails, the file handle pointer is not valid and must not
be dereferenced.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
lib/efi_loader/efi_capsule.c

index 9ead0d2c7816e4627904eb3e9105c6481fa28288..60309d4a07d08e55130cc6e9f48a978772dcc5d1 100644 (file)
@@ -901,7 +901,8 @@ static efi_status_t efi_capsule_delete_file(const u16 *filename)
        /* ignore an error */
        EFI_CALL((*dirh->close)(dirh));
 
-       ret = EFI_CALL((*fh->delete)(fh));
+       if (ret == EFI_SUCCESS)
+               ret = EFI_CALL((*fh->delete)(fh));
 
        return ret;
 }