diff options
| author | wzt.wzt@gmail.com <wzt.wzt@gmail.com> | 2010-11-10 03:05:15 -0500 |
|---|---|---|
| committer | James Morris <jmorris@namei.org> | 2010-11-10 15:36:22 -0500 |
| commit | a26d279ea87e9fef2cf8a44b371e48e6091975a6 (patch) | |
| tree | fe1a1a007c0fc1419e8f8e3e845ad18a377569bc /security | |
| parent | 246c3fb16b08193837a8009ff15ef6908534ba71 (diff) | |
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: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security')
| -rw-r--r-- | security/apparmor/lsm.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index cf1de4462ccd..b7106f192b75 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c | |||
| @@ -922,7 +922,7 @@ static int __init apparmor_init(void) | |||
| 922 | error = register_security(&apparmor_ops); | 922 | error = register_security(&apparmor_ops); |
| 923 | if (error) { | 923 | if (error) { |
| 924 | AA_ERROR("Unable to register AppArmor\n"); | 924 | AA_ERROR("Unable to register AppArmor\n"); |
| 925 | goto register_security_out; | 925 | goto set_init_cxt_out; |
| 926 | } | 926 | } |
| 927 | 927 | ||
| 928 | /* Report that AppArmor successfully initialized */ | 928 | /* Report that AppArmor successfully initialized */ |
| @@ -936,6 +936,9 @@ static int __init apparmor_init(void) | |||
| 936 | 936 | ||
| 937 | return error; | 937 | return error; |
| 938 | 938 | ||
| 939 | set_init_cxt_out: | ||
| 940 | aa_free_task_context(current->real_cred->security); | ||
| 941 | |||
| 939 | register_security_out: | 942 | register_security_out: |
| 940 | aa_free_root_ns(); | 943 | aa_free_root_ns(); |
| 941 | 944 | ||
| @@ -944,7 +947,6 @@ alloc_out: | |||
| 944 | 947 | ||
| 945 | apparmor_enabled = 0; | 948 | apparmor_enabled = 0; |
| 946 | return error; | 949 | return error; |
| 947 | |||
| 948 | } | 950 | } |
| 949 | 951 | ||
| 950 | security_initcall(apparmor_init); | 952 | security_initcall(apparmor_init); |
