Skip to content

Commit

Permalink
APPARMOR: Fix memory leak of apparmor_init()
Browse files Browse the repository at this point in the history
set_init_cxt() allocted sizeof(struct aa_task_cxt) bytes for cxt,
if register_security() failed, it will cause memory leak.

Signed-off-by: Zhitong Wang <[email protected]>
Signed-off-by: John Johansen <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
cloudsec authored and James Morris committed Nov 10, 2010
1 parent 246c3fb commit a26d279
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions security/apparmor/lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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();

Expand All @@ -944,7 +947,6 @@ static int __init apparmor_init(void)

apparmor_enabled = 0;
return error;

}

security_initcall(apparmor_init);

0 comments on commit a26d279

Please sign in to comment.