wlcore: use memdup_user
Use memdup_user() helper instead of open-coding to simplify the code. Signed-off-by: Geliang Tang <geliangtang@gmail.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
This commit is contained in:
parent
6d7d579a82
commit
6a01d48d47
|
@ -1149,15 +1149,9 @@ static ssize_t dev_mem_write(struct file *file, const char __user *user_buf,
|
||||||
part.mem.start = *ppos;
|
part.mem.start = *ppos;
|
||||||
part.mem.size = bytes;
|
part.mem.size = bytes;
|
||||||
|
|
||||||
buf = kmalloc(bytes, GFP_KERNEL);
|
buf = memdup_user(user_buf, bytes);
|
||||||
if (!buf)
|
if (IS_ERR(buf))
|
||||||
return -ENOMEM;
|
return PTR_ERR(buf);
|
||||||
|
|
||||||
ret = copy_from_user(buf, user_buf, bytes);
|
|
||||||
if (ret) {
|
|
||||||
ret = -EFAULT;
|
|
||||||
goto err_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
mutex_lock(&wl->mutex);
|
mutex_lock(&wl->mutex);
|
||||||
|
|
||||||
|
@ -1197,7 +1191,6 @@ skip_write:
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
*ppos += bytes;
|
*ppos += bytes;
|
||||||
|
|
||||||
err_out:
|
|
||||||
kfree(buf);
|
kfree(buf);
|
||||||
|
|
||||||
return ((ret == 0) ? bytes : ret);
|
return ((ret == 0) ? bytes : ret);
|
||||||
|
|
Loading…
Reference in New Issue