We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4519108 commit 03c9e6fCopy full SHA for 03c9e6f
drivers/ntb/test/ntb_tool.c
@@ -370,16 +370,9 @@ static ssize_t tool_fn_write(struct tool_ctx *tc,
370
if (*offp)
371
return 0;
372
373
- buf = kmalloc(size + 1, GFP_KERNEL);
374
- if (!buf)
375
- return -ENOMEM;
376
-
377
- if (copy_from_user(buf, ubuf, size)) {
378
- kfree(buf);
379
- return -EFAULT;
380
- }
381
382
- buf[size] = 0;
+ buf = memdup_user_nul(ubuf, size);
+ if (IS_ERR(buf))
+ return PTR_ERR(buf);
383
384
n = sscanf(buf, "%c %lli", &cmd, &bits);
385
0 commit comments