From: Thomas Huth <thuth@redhat.com>
To: Kees Cook <kees@kernel.org>, ony Luck <tony.luck@intel.com>,
linux-efi@vger.kernel.org
Cc: "Guilherme G. Piccoli" <gpiccoli@igalia.com>,
Ard Biesheuvel <ardb@kernel.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH] efi: pstore: Drop efivar lock when efi_pstore_open() returns with an error
Date: Mon, 27 Apr 2026 17:56:30 +0200 [thread overview]
Message-ID: <20260427155630.1966791-1-thuth@redhat.com> (raw)
From: Thomas Huth <thuth@redhat.com>
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>
---
drivers/firmware/efi/efi-pstore.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
index a253b61449459..a5db3534f0a63 100644
--- a/drivers/firmware/efi/efi-pstore.c
+++ b/drivers/firmware/efi/efi-pstore.c
@@ -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;
}
--
2.53.0
next reply other threads:[~2026-04-27 15:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 15:56 Thomas Huth [this message]
2026-04-27 16:10 ` [PATCH] efi: pstore: Drop efivar lock when efi_pstore_open() returns with an error Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260427155630.1966791-1-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=ardb@kernel.org \
--cc=gpiccoli@igalia.com \
--cc=ilias.apalodimas@linaro.org \
--cc=kees@kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox