summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorJianglei Nie <niejianglei2021@163.com>2022-07-12 09:10:37 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-07-21 21:20:11 +0200
commitc1d9702ceb4a091da6bee380627596d1fba09274 (patch)
tree94b61fafa86c69c8fffcac8ec2507851cc747959 /security
parenteb360267e1e972475023d06546e18365a222698c (diff)
ima: Fix potential memory leak in ima_init_crypto()
[ Upstream commit 067d2521874135267e681c19d42761c601d503d6 ] On failure to allocate the SHA1 tfm, IMA fails to initialize and exits without freeing the ima_algo_array. Add the missing kfree() for ima_algo_array to avoid the potential memory leak. Signed-off-by: Jianglei Nie <niejianglei2021@163.com> Fixes: 6d94809af6b0 ("ima: Allocate and initialize tfm for each PCR bank") Signed-off-by: Mimi Zohar <zohar@linux.ibm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'security')
-rw-r--r--security/integrity/ima/ima_crypto.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c
index f6a7e9643b54..b1e5e7749e41 100644
--- a/security/integrity/ima/ima_crypto.c
+++ b/security/integrity/ima/ima_crypto.c
@@ -205,6 +205,7 @@ out_array:
crypto_free_shash(ima_algo_array[i].tfm);
}
+ kfree(ima_algo_array);
out:
crypto_free_shash(ima_shash_tfm);
return rc;