[PATCH] security:trusted_tpm2: Fix memory leak in tpm2_key_encode()
Jarkko Sakkinen
jarkko at kernel.org
Tue Jun 7 10:09:56 UTC 2022
"KEYS: trusted: fix memory leak in tpm2_key_encode()"
On Tue, Jun 07, 2022 at 03:46:50PM +0800, Jianglei Nie wrote:
> The function allocates a memory chunk for scratch by kmalloc(), but
~~~ ~~
from with
There's more than one function in Linux - maybe you'd rather want
to write: "tpm2_key_encode() allocates ..."
> it is never freed through the function, which leads to a memory leak.
You can just write "it is never freed, which leads to a memory leak."
> Handle those cases with kfree().
"Free the memory chunk with kfree() in the return paths."
> Signed-off-by: Jianglei Nie <niejianglei2021 at 163.com>
Thank you finding this and providing a fix, it is highly appreciated.
Please don't take the nitpicking with the language personally. Just want
to have it documented in appropriate form.
BR, Jarkko
More information about the Linux-security-module-archive
mailing list