提交 a26d279e 编写于 作者: W wzt.wzt@gmail.com 提交者: James Morris

APPARMOR: Fix memory leak of apparmor_init()

set_init_cxt() allocted sizeof(struct aa_task_cxt) bytes for cxt,
if register_security() failed, it will cause memory leak.
Signed-off-by: NZhitong Wang <zhitong.wangzt@alibaba-inc.com>
Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
Signed-off-by: NJames Morris <jmorris@namei.org>
上级 246c3fb1
......@@ -922,7 +922,7 @@ static int __init apparmor_init(void)
error = register_security(&apparmor_ops);
if (error) {
AA_ERROR("Unable to register AppArmor\n");
goto register_security_out;
goto set_init_cxt_out;
}
/* Report that AppArmor successfully initialized */
......@@ -936,6 +936,9 @@ static int __init apparmor_init(void)
return error;
set_init_cxt_out:
aa_free_task_context(current->real_cred->security);
register_security_out:
aa_free_root_ns();
......@@ -944,7 +947,6 @@ static int __init apparmor_init(void)
apparmor_enabled = 0;
return error;
}
security_initcall(apparmor_init);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册