Commit e7662cb9 authored by Zou Wei's avatar Zou Wei Committed by Herbert Xu

crypto: hisilicon - switch to memdup_user_nul()

Use memdup_user_nul() helper instead of open-coding to
simplify the code.

v1-->v2:
   fixed patch title error
v2-->v3:
   return the actual error
Reported-by: default avatarHulk Robot <hulkci@huawei.com>
Signed-off-by: default avatarZou Wei <zou_wei@huawei.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent a5c164b1
......@@ -1603,16 +1603,9 @@ static ssize_t qm_cmd_write(struct file *filp, const char __user *buffer,
if (count > QM_DBG_WRITE_LEN)
return -ENOSPC;
cmd_buf = kzalloc(count + 1, GFP_KERNEL);
if (!cmd_buf)
return -ENOMEM;
if (copy_from_user(cmd_buf, buffer, count)) {
kfree(cmd_buf);
return -EFAULT;
}
cmd_buf[count] = '\0';
cmd_buf = memdup_user_nul(buffer, count);
if (IS_ERR(cmd_buf))
return PTR_ERR(cmd_buf);
cmd_buf_tmp = strchr(cmd_buf, '\n');
if (cmd_buf_tmp) {
......
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