X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=fs%2Fsysfs%2Fbin.c;h=9345806c8853e369ba34695542081bb2e3f347db;hb=fc2e3180a714d3125fc883541c0cd5936c99ba34;hp=93e0c0281d4511cc1319bcb0fdb2ed05eb1453a4;hpb=34e51ce60a210094bd66cf0a75dd8512247618ca;p=karo-tx-linux.git diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c index 93e0c0281d45..9345806c8853 100644 --- a/fs/sysfs/bin.c +++ b/fs/sysfs/bin.c @@ -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); @@ -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; }