Skip to content

Commit

Permalink
sysfs: use memdup_user()
Browse files Browse the repository at this point in the history
Remove open-coded memdup_user().

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Li Zefan authored and Al Viro committed Apr 21, 2009
1 parent dae7b66 commit 1c8542c
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions fs/sysfs/bin.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,9 @@ static ssize_t write(struct file *file, const char __user *userbuf,
count = size - offs;
}

temp = kmalloc(count, GFP_KERNEL);
if (!temp)
return -ENOMEM;

if (copy_from_user(temp, userbuf, count)) {
count = -EFAULT;
goto out_free;
}
temp = memdup_user(userbuf, count);
if (IS_ERR(temp))
return PTR_ERR(temp);

mutex_lock(&bb->mutex);

Expand All @@ -176,8 +171,6 @@ static ssize_t write(struct file *file, const char __user *userbuf,
if (count > 0)
*off = offs + count;

out_free:
kfree(temp);
return count;
}

Expand Down

0 comments on commit 1c8542c

Please sign in to comment.