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:
wzt.wzt@gmail.com 2010-11-10 11:31:55 +08:00 committed by James Morris
parent f6614b7bb4
commit 246c3fb16b

View File

@ -306,7 +306,7 @@ static struct aa_namespace *alloc_namespace(const char *prefix,
return ns;
fail_unconfined:
kzfree(ns->base.name);
kzfree(ns->base.hname);
fail_ns:
kzfree(ns);
return NULL;