mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
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: Ruan Jinjie <ruanjinjie@huawei.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Serge Semin <fancer.lancer@gmail.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
This commit is contained in:
parent
45191087c3
commit
03c9e6f0e0
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user