KEYS: trusted: Fix memory leak in tpm2_key_encode()
authorJarkko Sakkinen <jarkko@kernel.org>
Sun, 19 May 2024 23:31:53 +0000 (02:31 +0300)
committerJarkko Sakkinen <jarkko@kernel.org>
Mon, 20 May 2024 23:35:10 +0000 (02:35 +0300)
commitffcaa2172cc1a85ddb8b783de96d38ca8855e248
treebda8eb49bd902c3df46cce6d358c77178ed4f63c
parent8f6a15f095a63a83b096d9b29aaff4f0fbe6f6e6
KEYS: trusted: Fix memory leak in tpm2_key_encode()

'scratch' is never freed. Fix this by calling kfree() in the success, and
in the error case.

Cc: stable@vger.kernel.org # +v5.13
Fixes: f2219745250f ("security: keys: trusted: use ASN.1 TPM2 key format for the blobs")
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
security/keys/trusted-keys/trusted_tpm2.c