diff options
Diffstat (limited to 'drivers/ntb/test/ntb_tool.c')
-rw-r--r-- | drivers/ntb/test/ntb_tool.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/ntb/test/ntb_tool.c b/drivers/ntb/test/ntb_tool.c index e0acc11d29ba..641cb7e05a47 100644 --- a/drivers/ntb/test/ntb_tool.c +++ b/drivers/ntb/test/ntb_tool.c @@ -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); |