[apparmor] [PATCH] APPARMOR: Fix memory leak of alloc_namespace()

wzt.wzt at gmail.com wzt.wzt at gmail.com
Wed Nov 10 03:31:55 GMT 2010


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 at alibaba-inc.com>

---
 security/apparmor/policy.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c
index 52cc865..4f0eade 100644
--- a/security/apparmor/policy.c
+++ b/security/apparmor/policy.c
@@ -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;
-- 
1.6.5.3




More information about the AppArmor mailing list