* [Nouveau] [PATCH] drm: nouveau: use vmemdup_user instead of kvmalloc and copy_from_user
@ 2021-12-14 12:17 Qing Wang
0 siblings, 0 replies; only message in thread
From: Qing Wang @ 2021-12-14 12:17 UTC (permalink / raw)
To: Ben Skeggs, David Airlie, Daniel Vetter, dri-devel, nouveau,
linux-kernel
Cc: Wang Qing
From: Wang Qing <wangqing@vivo.com>
fix memdup_user.cocci warning:
nouveau_gem.c:630:7-15: WARNING opportunity for vmemdup_user
Signed-off-by: Wang Qing <wangqing@vivo.com>
---
drivers/gpu/drm/nouveau/nouveau_gem.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 9416bee..befb864
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -627,16 +627,7 @@ u_memcpya(uint64_t user, unsigned nmemb, unsigned size)
size *= nmemb;
- mem = kvmalloc(size, GFP_KERNEL);
- if (!mem)
- return ERR_PTR(-ENOMEM);
-
- if (copy_from_user(mem, userptr, size)) {
- u_free(mem);
- return ERR_PTR(-EFAULT);
- }
-
- return mem;
+ return vmemdup_user(userptr, size);
}
static int
--
2.7.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-12-14 12:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 12:17 [Nouveau] [PATCH] drm: nouveau: use vmemdup_user instead of kvmalloc and copy_from_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;
as well as URLs for NNTP newsgroup(s).