staging: greybus: camera: Switch to memdup_user_nul()
Use memdup_user_nul() helper instead of open-coding to simplify the code. Reported-by: Hulk Robot <hulkci@huawei.com> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Link: https://lore.kernel.org/r/20210401103645.1558813-1-yangyingliang@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
0778f04b0b
commit
f032e2cdf9
@ -1120,16 +1120,9 @@ static ssize_t gb_camera_debugfs_write(struct file *file,
|
|||||||
if (len > 1024)
|
if (len > 1024)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
kbuf = kmalloc(len + 1, GFP_KERNEL);
|
kbuf = memdup_user_nul(buf, len);
|
||||||
if (!kbuf)
|
if (IS_ERR(kbuf))
|
||||||
return -ENOMEM;
|
return PTR_ERR(kbuf);
|
||||||
|
|
||||||
if (copy_from_user(kbuf, buf, len)) {
|
|
||||||
ret = -EFAULT;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
kbuf[len] = '\0';
|
|
||||||
|
|
||||||
ret = op->execute(gcam, kbuf, len);
|
ret = op->execute(gcam, kbuf, len);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user