lkml.org 
[lkml]   [2021]   [Oct]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] firmware: tegra: switch over to memdup_user()
On Mon, Oct 18, 2021 at 12:59:40AM -0700, Qing Wang wrote:
[...]
> --- a/drivers/firmware/tegra/bpmp-debugfs.c
> +++ b/drivers/firmware/tegra/bpmp-debugfs.c
> @@ -376,18 +376,11 @@ static ssize_t bpmp_debug_store(struct file *file, const char __user *buf,
> if (!filename)
> return -ENOENT;
>
> - databuf = kmalloc(count, GFP_KERNEL);
> - if (!databuf)
> - return -ENOMEM;
> -
> - if (copy_from_user(databuf, buf, count)) {
> - err = -EFAULT;
> - goto free_ret;
> - }
> + databuf = memdup_user(buf, count);
> + if (IS_ERR(databuf))
> + return ERR_PTR(PTR_ERR(databuf));

ERR_PTR() is too much here.

Best Regards
Michał Mirosław

\
 
 \ /
  Last update: 2021-10-21 03:17    [W:0.099 / U:0.576 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site