* [PATCH] gpu: drm: tegra: switch over to vmemdup_user()
@ 2021-10-18 8:00 Qing Wang
0 siblings, 0 replies; only message in thread
From: Qing Wang @ 2021-10-18 8:00 UTC (permalink / raw)
To: Thierry Reding, David Airlie, Daniel Vetter, Jonathan Hunter,
dri-devel, linux-tegra, linux-kernel
Cc: Qing Wang
This patch fixes the following Coccinelle warning:
drivers/gpu/drm/tegra/submit.c:173:8-15: 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>
---
drivers/gpu/drm/tegra/submit.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/tegra/submit.c b/drivers/gpu/drm/tegra/submit.c
index c326984..0b11f1a
--- 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_PTR(PTR_ERR(data));
return data;
}
--
2.7.4
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-18 8:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-18 8:00 [PATCH] gpu: drm: tegra: switch over to vmemdup_user() Qing Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®