summaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorJames Morris <jmorris@namei.org>2008-12-29 09:57:38 +1100
committerJames Morris <jmorris@namei.org>2008-12-29 09:57:38 +1100
commit54d2f649a67109d877ca143c09cdeba61fe51bcf (patch)
tree3ecea866513c1d95831c3e13b359ad8d631de1c7 /security
parent541ef5cbb8e68189d47272cea52a69abc30259bc (diff)
parent81ea714bf148fce35e931edcbdfd3aedda20d1dc (diff)
downloadlinux-54d2f649a67109d877ca143c09cdeba61fe51bcf.tar.gz
linux-54d2f649a67109d877ca143c09cdeba61fe51bcf.tar.bz2
linux-54d2f649a67109d877ca143c09cdeba61fe51bcf.zip
Merge branch 'next' into for-linus
Diffstat (limited to 'security')
-rw-r--r--security/smack/smackfs.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index ca257dfdc75d..247dc9ebbc71 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -185,11 +185,15 @@ static int smk_open_load(struct inode *inode, struct file *file)
* the subject/object pair and replaces the access that was
* there. If the pair isn't found add it with the specified
* access.
+ *
+ * Returns 0 if nothing goes wrong or -ENOMEM if it fails
+ * during the allocation of the new pair to add.
*/
-static void smk_set_access(struct smack_rule *srp)
+static int smk_set_access(struct smack_rule *srp)
{
struct smk_list_entry *sp;
struct smk_list_entry *newp;
+ int ret = 0;
mutex_lock(&smack_list_lock);
@@ -202,14 +206,20 @@ static void smk_set_access(struct smack_rule *srp)
if (sp == NULL) {
newp = kzalloc(sizeof(struct smk_list_entry), GFP_KERNEL);
+ if (newp == NULL) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
newp->smk_rule = *srp;
newp->smk_next = smack_list;
smack_list = newp;
}
+out:
mutex_unlock(&smack_list_lock);
- return;
+ return ret;
}
/**
@@ -309,8 +319,10 @@ static ssize_t smk_write_load(struct file *file, const char __user *buf,
goto out;
}
- smk_set_access(&rule);
- rc = count;
+ rc = smk_set_access(&rule);
+
+ if (!rc)
+ rc = count;
out:
kfree(data);