APPARMOR: Fix memory leak of alloc_namespace()
policy->name is a substring of policy->hname, if prefix is not NULL, it will allocted strlen(prefix) + strlen(name) + 3 bytes to policy->hname in policy_init(). use kzfree(ns->base.name) will casue memory leak if alloc_namespace() failed. Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com> Signed-off-by: John Johansen <john.johansen@canonical.com> Signed-off-by: James Morris <jmorris@namei.org>
This commit is contained in:
parent
f6614b7bb4
commit
246c3fb16b
@ -306,7 +306,7 @@ static struct aa_namespace *alloc_namespace(const char *prefix,
|
|||||||
return ns;
|
return ns;
|
||||||
|
|
||||||
fail_unconfined:
|
fail_unconfined:
|
||||||
kzfree(ns->base.name);
|
kzfree(ns->base.hname);
|
||||||
fail_ns:
|
fail_ns:
|
||||||
kzfree(ns);
|
kzfree(ns);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user