diff options
author | Qing Wang <wangqing@vivo.com> | 2021-10-18 04:31:52 -0700 |
---|---|---|
committer | Thierry Reding <treding@nvidia.com> | 2022-09-15 12:45:42 +0200 |
commit | fa586abcfe4b43e170d72586b6f11bcc48f6766c (patch) | |
tree | f5617ec2d1498d6849e245be8314b1d6e57ceee2 /drivers/firmware | |
parent | 568035b01cfb107af8d2e4bd2fb9aea22cf5b868 (diff) |
firmware: tegra: Switch over to memdup_user()
This patch fixes the following Coccinelle warning:
drivers/firmware/tegra/bpmp-debugfs.c:379: WARNING opportunity for memdup_user
Use memdup_user() rather than duplicating its implementation. This is a
little bit restricted to reduce false positives.
Signed-off-by: Qing Wang <wangqing@vivo.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'drivers/firmware')
-rw-r--r-- | drivers/firmware/tegra/bpmp-debugfs.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/firmware/tegra/bpmp-debugfs.c b/drivers/firmware/tegra/bpmp-debugfs.c index 0c440afd5224..9d3874cdaaee 100644 --- a/drivers/firmware/tegra/bpmp-debugfs.c +++ b/drivers/firmware/tegra/bpmp-debugfs.c @@ -377,18 +377,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 PTR_ERR(databuf); err = mrq_debug_write(bpmp, filename, databuf, count); - -free_ret: kfree(databuf); return err ?: count; |