diff options
author | John Johansen <john.johansen@canonical.com> | 2013-02-21 16:25:44 -0500 |
---|---|---|
committer | John Johansen <john.johansen@canonical.com> | 2013-04-28 03:39:35 -0400 |
commit | 53fe8b9961716033571d9799005bfdbbafa5162c (patch) | |
tree | 65e4a560f30d7b929059cd5cf9814b700e791a52 /security | |
parent | 41d1b3e868c263e8b43dd5903a70633e05ae58a6 (diff) |
apparmor: fix sparse warnings
Fix a couple of warning reported by sparse
Signed-off-by: John Johansen <john.johansen@canonical.com>
Diffstat (limited to 'security')
-rw-r--r-- | security/apparmor/include/file.h | 14 | ||||
-rw-r--r-- | security/apparmor/lsm.c | 8 |
2 files changed, 11 insertions, 11 deletions
diff --git a/security/apparmor/include/file.h b/security/apparmor/include/file.h index 967b2deda376..2c922b86bd44 100644 --- a/security/apparmor/include/file.h +++ b/security/apparmor/include/file.h | |||
@@ -186,11 +186,6 @@ static inline void aa_free_file_rules(struct aa_file_rules *rules) | |||
186 | aa_free_domain_entries(&rules->trans); | 186 | aa_free_domain_entries(&rules->trans); |
187 | } | 187 | } |
188 | 188 | ||
189 | #define ACC_FMODE(x) (("\000\004\002\006"[(x)&O_ACCMODE]) | (((x) << 1) & 0x40)) | ||
190 | |||
191 | /* from namei.c */ | ||
192 | #define MAP_OPEN_FLAGS(x) ((((x) + 1) & O_ACCMODE) ? (x) + 1 : (x)) | ||
193 | |||
194 | /** | 189 | /** |
195 | * aa_map_file_perms - map file flags to AppArmor permissions | 190 | * aa_map_file_perms - map file flags to AppArmor permissions |
196 | * @file: open file to map flags to AppArmor permissions | 191 | * @file: open file to map flags to AppArmor permissions |
@@ -199,8 +194,13 @@ static inline void aa_free_file_rules(struct aa_file_rules *rules) | |||
199 | */ | 194 | */ |
200 | static inline u32 aa_map_file_to_perms(struct file *file) | 195 | static inline u32 aa_map_file_to_perms(struct file *file) |
201 | { | 196 | { |
202 | int flags = MAP_OPEN_FLAGS(file->f_flags); | 197 | int flags = file->f_flags; |
203 | u32 perms = ACC_FMODE(file->f_mode); | 198 | u32 perms = 0; |
199 | |||
200 | if (file->f_mode & FMODE_WRITE) | ||
201 | perms |= MAY_WRITE; | ||
202 | if (file->f_mode & FMODE_READ) | ||
203 | perms |= MAY_READ; | ||
204 | 204 | ||
205 | if ((flags & O_APPEND) && (perms & MAY_WRITE)) | 205 | if ((flags & O_APPEND) && (perms & MAY_WRITE)) |
206 | perms = (perms & ~MAY_WRITE) | MAY_APPEND; | 206 | perms = (perms & ~MAY_WRITE) | MAY_APPEND; |
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index ed7e3aadba3a..10843aa5a368 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c | |||
@@ -909,8 +909,11 @@ static int __init apparmor_init(void) | |||
909 | 909 | ||
910 | error = register_security(&apparmor_ops); | 910 | error = register_security(&apparmor_ops); |
911 | if (error) { | 911 | if (error) { |
912 | struct cred *cred = (struct cred *)current->real_cred; | ||
913 | aa_free_task_context(cred->security); | ||
914 | cred->security = NULL; | ||
912 | AA_ERROR("Unable to register AppArmor\n"); | 915 | AA_ERROR("Unable to register AppArmor\n"); |
913 | goto set_init_cxt_out; | 916 | goto register_security_out; |
914 | } | 917 | } |
915 | 918 | ||
916 | /* Report that AppArmor successfully initialized */ | 919 | /* Report that AppArmor successfully initialized */ |
@@ -924,9 +927,6 @@ static int __init apparmor_init(void) | |||
924 | 927 | ||
925 | return error; | 928 | return error; |
926 | 929 | ||
927 | set_init_cxt_out: | ||
928 | aa_free_task_context(current->real_cred->security); | ||
929 | |||
930 | register_security_out: | 930 | register_security_out: |
931 | aa_free_root_ns(); | 931 | aa_free_root_ns(); |
932 | 932 | ||