apparmor: Fix memleak issue in unpack_profile()
authorXiu Jianfeng <xiujianfeng@huawei.com>
Fri, 21 Oct 2022 09:36:02 +0000 (17:36 +0800)
committerJohn Johansen <john.johansen@canonical.com>
Tue, 25 Oct 2022 07:15:19 +0000 (00:15 -0700)
commit3265949f7cd36a724a35020202c618094be1cf28
treef3c973e9357a5bcce469549689065b222e660275
parent7dd426e33e2f9275ac03a306efdc89aa86515a52
apparmor: Fix memleak issue in unpack_profile()

Before aa_alloc_profile(), it has allocated string for @*ns_name if @tmpns
is not NULL, so directly return -ENOMEM if aa_alloc_profile() failed will
cause a memleak issue, and even if aa_alloc_profile() succeed, in the
@fail_profile tag of aa_unpack(), it need to free @ns_name as well, this
patch fixes them.

Fixes: 736ec752d95e ("AppArmor: policy routines for loading and unpacking policy")
Fixes: 04dc715e24d0 ("apparmor: audit policy ns specified in policy load")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/policy_unpack.c