aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorJames Morris <jmorris@namei.org>2008-12-28 17:57:38 -0500
committerJames Morris <jmorris@namei.org>2008-12-28 17:57:38 -0500
commit54d2f649a67109d877ca143c09cdeba61fe51bcf (patch)
tree3ecea866513c1d95831c3e13b359ad8d631de1c7 /security
parent541ef5cbb8e68189d47272cea52a69abc30259bc (diff)
parent81ea714bf148fce35e931edcbdfd3aedda20d1dc (diff)
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)
185 * the subject/object pair and replaces the access that was 185 * the subject/object pair and replaces the access that was
186 * there. If the pair isn't found add it with the specified 186 * there. If the pair isn't found add it with the specified
187 * access. 187 * access.
188 *
189 * Returns 0 if nothing goes wrong or -ENOMEM if it fails
190 * during the allocation of the new pair to add.
188 */ 191 */
189static void smk_set_access(struct smack_rule *srp) 192static int smk_set_access(struct smack_rule *srp)
190{ 193{
191 struct smk_list_entry *sp; 194 struct smk_list_entry *sp;
192 struct smk_list_entry *newp; 195 struct smk_list_entry *newp;
196 int ret = 0;
193 197
194 mutex_lock(&smack_list_lock); 198 mutex_lock(&smack_list_lock);
195 199
@@ -202,14 +206,20 @@ static void smk_set_access(struct smack_rule *srp)
202 206
203 if (sp == NULL) { 207 if (sp == NULL) {
204 newp = kzalloc(sizeof(struct smk_list_entry), GFP_KERNEL); 208 newp = kzalloc(sizeof(struct smk_list_entry), GFP_KERNEL);
209 if (newp == NULL) {
210 ret = -ENOMEM;
211 goto out;
212 }
213
205 newp->smk_rule = *srp; 214 newp->smk_rule = *srp;
206 newp->smk_next = smack_list; 215 newp->smk_next = smack_list;
207 smack_list = newp; 216 smack_list = newp;
208 } 217 }
209 218
219out:
210 mutex_unlock(&smack_list_lock); 220 mutex_unlock(&smack_list_lock);
211 221
212 return; 222 return ret;
213} 223}
214 224
215/** 225/**
@@ -309,8 +319,10 @@ static ssize_t smk_write_load(struct file *file, const char __user *buf,
309 goto out; 319 goto out;
310 } 320 }
311 321
312 smk_set_access(&rule); 322 rc = smk_set_access(&rule);
313 rc = count; 323
324 if (!rc)
325 rc = count;
314 326
315out: 327out:
316 kfree(data); 328 kfree(data);