Commit 246c3fb1 authored by wzt.wzt@gmail.com's avatar wzt.wzt@gmail.com Committed by James Morris

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: default avatarZhitong Wang <zhitong.wangzt@alibaba-inc.com>
Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent f6614b7b
...@@ -306,7 +306,7 @@ static struct aa_namespace *alloc_namespace(const char *prefix, ...@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment