]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
efi: pstore: Drop efivar lock when efi_pstore_open() returns with an error
authorThomas Huth <thuth@redhat.com>
Mon, 27 Apr 2026 15:56:30 +0000 (17:56 +0200)
committerArd Biesheuvel <ardb@kernel.org>
Tue, 28 Apr 2026 10:31:02 +0000 (12:31 +0200)
If kzalloc fails, the function returns -ENOMEM without calling
efivar_unlock(). Since open() returned  an error, the calling site
in pstore_get_backend_records() won't call the close() function, so
the lock is never released. Thus drop the lock in case of errors here.

Fixes: 859748255b434 ("efi: pstore: Omit efivars caching EFI varstore access layer")
Assisted-by: Claude:claude-opus-4-6
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/efi-pstore.c

index a253b61449459eca31afc6ca780a20c4557659ba..a5db3534f0a632ac661976f1e85c52258b0868e3 100644 (file)
@@ -60,8 +60,10 @@ static int efi_pstore_open(struct pstore_info *psi)
                return err;
 
        psi->data = kzalloc(record_size, GFP_KERNEL);
-       if (!psi->data)
+       if (!psi->data) {
+               efivar_unlock();
                return -ENOMEM;
+       }
 
        return 0;
 }