Commit 20fd4f42 authored by Wei Yongjun's avatar Wei Yongjun Committed by David S. Miller

netdevsim: switch to memdup_user_nul()

Use memdup_user_nul() helper instead of open-coding to
simplify the code.
Reported-by: default avatarHulk Robot <hulkci@huawei.com>
Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c3dde0ee
...@@ -235,15 +235,10 @@ static ssize_t nsim_dev_health_break_write(struct file *file, ...@@ -235,15 +235,10 @@ static ssize_t nsim_dev_health_break_write(struct file *file,
char *break_msg; char *break_msg;
int err; int err;
break_msg = kmalloc(count + 1, GFP_KERNEL); break_msg = memdup_user_nul(data, count);
if (!break_msg) if (IS_ERR(break_msg))
return -ENOMEM; return PTR_ERR(break_msg);
if (copy_from_user(break_msg, data, count)) {
err = -EFAULT;
goto out;
}
break_msg[count] = '\0';
if (break_msg[count - 1] == '\n') if (break_msg[count - 1] == '\n')
break_msg[count - 1] = '\0'; break_msg[count - 1] = '\0';
......
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