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] tpm: acpi: Fix memory leak at tpm_read_log_acpi() error path
Date: Mon, 9 Nov 2026 17:25:45 +0200 [thread overview]
Message-ID: <avHl-WoBP73QjInD@kernel.org> (raw)
In-Reply-To: <20261109082527.541901-1-tiwai@suse.de>
On Mon, Nov 09, 2026 at 09:25:24AM +0100, Takashi Iwai wrote:
> When devm_add_action() returns an error, we do NULL-clear
> log->bios_event_log unnecessarily before calling tpm_bios_log_free(),
> and it would lead to a memory leak of the allocated log buffer.
I don't understand this. "NULL-clear" is gibberish when the actual
bug is just spurious clear of log->bios_event_log. Also we are not
doing anything we are not computers.
>
> Fix it by simply jumping to the err.
>
> Fixes: a3a860bc0fd6 ("tpm: Change to kvalloc() in eventlog/acpi.c")
> Cc: <stable@vger.kernel.org>
Put Cc before fixes.
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
> 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
>
Br, Jarkko
next prev parent reply other threads:[~2026-11-09 15:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 8:25 Takashi Iwai
2026-11-09 15:25 ` Jarkko Sakkinen [this message]
2026-11-09 15:26 ` 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=avHl-WoBP73QjInD@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®