public inbox for linux-efi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ardb@kernel.org>
To: "Thomas Huth" <thuth@redhat.com>, "Kees Cook" <kees@kernel.org>,
	"Tony Luck" <tony.luck@intel.com>,
	linux-efi@vger.kernel.org
Cc: "Guilherme G. Piccoli" <gpiccoli@igalia.com>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] efi: pstore: Drop efivar lock when efi_pstore_open() returns with an error
Date: Mon, 27 Apr 2026 18:10:35 +0200	[thread overview]
Message-ID: <5b4e6b16-3018-40ad-b66a-a228e342c679@app.fastmail.com> (raw)
In-Reply-To: <20260427155630.1966791-1-thuth@redhat.com>

Hi Thomas,

On Mon, 27 Apr 2026, at 17:56, Thomas Huth wrote:
> 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(-)
>

Queued in efi/urgent - thanks.

> 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

      reply	other threads:[~2026-04-27 16:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=5b4e6b16-3018-40ad-b66a-a228e342c679@app.fastmail.com \
    --to=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=thuth@redhat.com \
    --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