Re: [PATCH] tpm: acpi: Fix memory leak at tpm_read_log_acpi() error path

From: Jarkko Sakkinen

Date: Mon Nov 09 2026 - 11:50:52 EST


On Mon, Nov 09, 2026 at 04:55:03PM +0100, Takashi Iwai wrote:
> On Mon, 09 Nov 2026 16:25:45 +0100,
> Jarkko Sakkinen wrote:
> >
> > 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.
>
> It's not "spurious", but rather ill-behaving.
> Because it sets NULL before calling tpm_bios_log_free(), the actually
> allocated buffer won't be freed at all.

I agree. That was wrong choice of the word from my side :-)

Since in this case it simple, I'd just want to apples and oranges
pointed out, that's all.


>
>
> Takashi

Br, Jarkko