Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 298648
b: refs/heads/master
c: 44c8249
h: refs/heads/master
v: v3
  • Loading branch information
Andrew Morton authored and Linus Torvalds committed Apr 5, 2012
1 parent d32d99b commit a014f54
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0d08d7b7e13b5060181b11ecdde82d8fda322123
refs/heads/master: 44c824982fd37a578da23cc90885e9690a6a3f0e
21 changes: 17 additions & 4 deletions trunk/fs/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
{
int error;
void *kvalue = NULL;
void *vvalue = NULL; /* If non-NULL, we used vmalloc() */
char kname[XATTR_NAME_MAX + 1];

if (flags & ~(XATTR_CREATE|XATTR_REPLACE))
Expand All @@ -335,13 +336,25 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
if (size) {
if (size > XATTR_SIZE_MAX)
return -E2BIG;
kvalue = memdup_user(value, size);
if (IS_ERR(kvalue))
return PTR_ERR(kvalue);
kvalue = kmalloc(size, GFP_KERNEL | __GFP_NOWARN);
if (!kvalue) {
vvalue = vmalloc(size);
if (!vvalue)
return -ENOMEM;
kvalue = vvalue;
}
if (copy_from_user(kvalue, value, size)) {
error = -EFAULT;
goto out;
}
}

error = vfs_setxattr(d, kname, kvalue, size, flags);
kfree(kvalue);
out:
if (vvalue)
vfree(vvalue);
else
kfree(kvalue);
return error;
}

Expand Down

0 comments on commit a014f54

Please sign in to comment.