mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-02 15:18:19 +00:00
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
1 changed files with 3 additions and 10 deletions
|
@ -1120,16 +1120,9 @@ static ssize_t gb_camera_debugfs_write(struct file *file,
|
|||
if (len > 1024)
|
||||
return -EINVAL;
|
||||
|
||||
kbuf = kmalloc(len + 1, GFP_KERNEL);
|
||||
if (!kbuf)
|
||||
return -ENOMEM;
|
||||
|
||||
if (copy_from_user(kbuf, buf, len)) {
|
||||
ret = -EFAULT;
|
||||
goto done;
|
||||
}
|
||||
|
||||
kbuf[len] = '\0';
|
||||
kbuf = memdup_user_nul(buf, len);
|
||||
if (IS_ERR(kbuf))
|
||||
return PTR_ERR(kbuf);
|
||||
|
||||
ret = op->execute(gcam, kbuf, len);
|
||||
|
||||
|
|
Loading…
Reference in a new issue