integrity: Fix memory leakage in keyring allocation error path
authorGUO Zihua <guozihua@huawei.com>
Fri, 11 Nov 2022 10:13:17 +0000 (18:13 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:32:11 +0000 (13:32 +0100)
commitc591c48842f08d30ec6b8416757831985ed9a315
treef01fbffbcaeb8d9b5b1ab5ae15c99e288ce4828b
parentaccc7993a780c5cd4e45051634bf66400df10f36
integrity: Fix memory leakage in keyring allocation error path

[ Upstream commit 39419ef7af0916cc3620ecf1ed42d29659109bf3 ]

Key restriction is allocated in integrity_init_keyring(). However, if
keyring allocation failed, it is not freed, causing memory leaks.

Fixes: 2b6aa412ff23 ("KEYS: Use structure to capture key restriction function and data")
Signed-off-by: GUO Zihua <guozihua@huawei.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
security/integrity/digsig.c