Commit 53fe8b99 authored by John Johansen's avatar John Johansen

apparmor: fix sparse warnings

Fix a couple of warning reported by sparse
Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
parent 41d1b3e8
...@@ -186,11 +186,6 @@ static inline void aa_free_file_rules(struct aa_file_rules *rules) ...@@ -186,11 +186,6 @@ static inline void aa_free_file_rules(struct aa_file_rules *rules)
aa_free_domain_entries(&rules->trans); aa_free_domain_entries(&rules->trans);
} }
#define ACC_FMODE(x) (("\000\004\002\006"[(x)&O_ACCMODE]) | (((x) << 1) & 0x40))
/* from namei.c */
#define MAP_OPEN_FLAGS(x) ((((x) + 1) & O_ACCMODE) ? (x) + 1 : (x))
/** /**
* aa_map_file_perms - map file flags to AppArmor permissions * aa_map_file_perms - map file flags to AppArmor permissions
* @file: open file to map flags to AppArmor permissions * @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,8 +194,13 @@ static inline void aa_free_file_rules(struct aa_file_rules *rules)
*/ */
static inline u32 aa_map_file_to_perms(struct file *file) static inline u32 aa_map_file_to_perms(struct file *file)
{ {
int flags = MAP_OPEN_FLAGS(file->f_flags); int flags = file->f_flags;
u32 perms = ACC_FMODE(file->f_mode); u32 perms = 0;
if (file->f_mode & FMODE_WRITE)
perms |= MAY_WRITE;
if (file->f_mode & FMODE_READ)
perms |= MAY_READ;
if ((flags & O_APPEND) && (perms & MAY_WRITE)) if ((flags & O_APPEND) && (perms & MAY_WRITE))
perms = (perms & ~MAY_WRITE) | MAY_APPEND; perms = (perms & ~MAY_WRITE) | MAY_APPEND;
......
...@@ -909,8 +909,11 @@ static int __init apparmor_init(void) ...@@ -909,8 +909,11 @@ static int __init apparmor_init(void)
error = register_security(&apparmor_ops); error = register_security(&apparmor_ops);
if (error) { if (error) {
struct cred *cred = (struct cred *)current->real_cred;
aa_free_task_context(cred->security);
cred->security = NULL;
AA_ERROR("Unable to register AppArmor\n"); AA_ERROR("Unable to register AppArmor\n");
goto set_init_cxt_out; goto register_security_out;
} }
/* Report that AppArmor successfully initialized */ /* Report that AppArmor successfully initialized */
...@@ -924,9 +927,6 @@ static int __init apparmor_init(void) ...@@ -924,9 +927,6 @@ static int __init apparmor_init(void)
return error; return error;
set_init_cxt_out:
aa_free_task_context(current->real_cred->security);
register_security_out: register_security_out:
aa_free_root_ns(); aa_free_root_ns();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment