CVE-2024-36967: KEYS: trusted: Fix memory leak in tpm2_key_encode()
requested to merge redhat/red-hat-ci-tools/kernel/bot-branches/centos-stream-9:backport-RHEL-41151-centos-stream-9-main into main
JIRA: https://issues.redhat.com/browse/RHEL-41151 CVE: CVE-2024-36967
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>
(cherry picked from commit ffcaa2172cc1a85ddb8b783de96d38ca8855e248)
Signed-off-by: CKI Backport Bot cki-ci-bot+cki-gitlab-backport-bot@redhat.com
Edited by Eric Sandeen