public inbox for linux-efi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efi: pstore: Drop efivar lock when efi_pstore_open() returns with an error
@ 2026-04-27 15:56 Thomas Huth
  2026-04-27 16:10 ` Ard Biesheuvel
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Huth @ 2026-04-27 15:56 UTC (permalink / raw)
  To: Kees Cook, ony Luck, linux-efi
  Cc: Guilherme G. Piccoli, Ard Biesheuvel, Ilias Apalodimas,
	linux-kernel

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-27 16:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 15:56 [PATCH] efi: pstore: Drop efivar lock when efi_pstore_open() returns with an error Thomas Huth
2026-04-27 16:10 ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox