Commit 03c9e6f0 authored by Ruan Jinjie's avatar Ruan Jinjie Committed by Jon Mason

NTB: ntb_tool: Switch to memdup_user_nul() helper

Use memdup_user_nul() helper instead of open-coding to simplify the code.
Signed-off-by: default avatarRuan Jinjie <ruanjinjie@huawei.com>
Reviewed-by: default avatarDave Jiang <dave.jiang@intel.com>
Reviewed-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: default avatarSerge Semin <fancer.lancer@gmail.com>
Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
parent 45191087
......@@ -370,16 +370,9 @@ static ssize_t tool_fn_write(struct tool_ctx *tc,
if (*offp)
return 0;
buf = kmalloc(size + 1, GFP_KERNEL);
if (!buf)
return -ENOMEM;
if (copy_from_user(buf, ubuf, size)) {
kfree(buf);
return -EFAULT;
}
buf[size] = 0;
buf = memdup_user_nul(ubuf, size);
if (IS_ERR(buf))
return PTR_ERR(buf);
n = sscanf(buf, "%c %lli", &cmd, &bits);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment