Skip to content

Commit

Permalink
APPARMOR: Fix memory leak of alloc_namespace()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
wzt.wzt@gmail.com authored and James Morris committed Nov 10, 2010
1 parent f6614b7 commit 246c3fb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion security/apparmor/policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 246c3fb

Please sign in to comment.