diff options
author | Qing Wang <wangqing@vivo.com> | 2021-10-18 14:31:26 +0300 |
---|---|---|
committer | Thierry Reding <treding@nvidia.com> | 2022-11-25 18:14:58 +0300 |
commit | bbdca2d41b6c9e2ca8e26ad65ec3d7a1fc7ec8db (patch) | |
tree | c72163f77ab9c0bbc823706ec40bf34336828ac7 /drivers/gpu/drm/tegra/submit.c | |
parent | 8935002fc37fce1ad211d98a70f2fd42083c0594 (diff) | |
download | linux-bbdca2d41b6c9e2ca8e26ad65ec3d7a1fc7ec8db.tar.xz |
drm/tegra: Switch over to vmemdup_user()
This patch fixes the following Coccinelle warning:
drivers/gpu/drm/tegra/submit.c:173: WARNING opportunity for vmemdup_user
Use vmemdup_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/gpu/drm/tegra/submit.c')
-rw-r--r-- | drivers/gpu/drm/tegra/submit.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/gpu/drm/tegra/submit.c b/drivers/gpu/drm/tegra/submit.c index b24738bdf3df..84041fc8239a 100644 --- a/drivers/gpu/drm/tegra/submit.c +++ b/drivers/gpu/drm/tegra/submit.c @@ -169,14 +169,9 @@ static void *alloc_copy_user_array(void __user *from, size_t count, size_t size) if (copy_len > 0x4000) return ERR_PTR(-E2BIG); - data = kvmalloc(copy_len, GFP_KERNEL); - if (!data) - return ERR_PTR(-ENOMEM); - - if (copy_from_user(data, from, copy_len)) { - kvfree(data); - return ERR_PTR(-EFAULT); - } + data = vmemdup_user(from, copy_len); + if (IS_ERR(data)) + return ERR_CAST(data); return data; } |