All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Takashi Iwai <tiwai@suse.de>
Cc: Peter Huewe <peterhuewe@gmx.de>, Jason Gunthorpe <jgg@ziepe.ca>,
	linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] tpm: acpi: Fix memory leak at tpm_read_log_acpi() error path
Date: Mon, 9 Nov 2026 20:42:11 +0200	[thread overview]
Message-ID: <avIUA2WeE51HVOEa@kernel.org> (raw)
In-Reply-To: <20261109173756.742248-1-tiwai@suse.de>

On Mon, Nov 09, 2026 at 06:37:52PM +0100, Takashi Iwai wrote:
> When devm_add_action() returns an error, tpm_read_log_acpi() clears
> log->bios_event_log unnecessarily to NULL before calling
> tpm_bios_log_free(), and it would lead to a memory leak of the
> allocated log buffer.
> 
> Fix it by simply jumping to the err.
> 
> Cc: <stable@vger.kernel.org>
> Fixes: a3a860bc0fd6 ("tpm: Change to kvalloc() in eventlog/acpi.c")
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
> v1->v2: minor update of patch description and tags order
> 
>  drivers/char/tpm/eventlog/acpi.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/char/tpm/eventlog/acpi.c b/drivers/char/tpm/eventlog/acpi.c
> index cf02ec646f46..50770cafa835 100644
> --- a/drivers/char/tpm/eventlog/acpi.c
> +++ b/drivers/char/tpm/eventlog/acpi.c
> @@ -167,10 +167,8 @@ int tpm_read_log_acpi(struct tpm_chip *chip)
>  	}
>  
>  	ret = devm_add_action(&chip->dev, tpm_bios_log_free, log->bios_event_log);
> -	if (ret) {
> -		log->bios_event_log = NULL;
> +	if (ret)
>  		goto err;
> -	}
>  
>  	return format;
>  
> -- 
> 2.53.0
> 

Thank you!


Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

Br, Jarkko

  reply	other threads:[~2026-11-09 18:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 17:37 [PATCH v2] tpm: acpi: Fix memory leak at tpm_read_log_acpi() error path Takashi Iwai
2026-11-09 18:42 ` Jarkko Sakkinen [this message]
2026-11-10 10:43 ` Paul Menzel
2026-11-10 12:56   ` Jarkko Sakkinen

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=avIUA2WeE51HVOEa@kernel.org \
    --to=jarkko@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=tiwai@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.