All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau/gem: Use vmemdup_user() rather than duplicating its implementation
@ 2020-08-11 17:56 ` Markus Elfring
  0 siblings, 0 replies; 14+ messages in thread
From: Markus Elfring @ 2020-08-11 17:56 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Ben Skeggs,
	Daniel Vetter, David Airlie
  Cc: Julia Lawall, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, LKML,
	Denis Efremov

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Tue, 11 Aug 2020 19:25:22 +0200

Reuse existing functionality from vmemdup_user() instead of keeping
duplicate source code.

Generated by: scripts/coccinelle/api/memdup_user.cocci

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 drivers/gpu/drm/nouveau/nouveau_gem.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 81f111ad3f4f..7ef6221408af 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -587,15 +587,9 @@ u_memcpya(uint64_t user, unsigned nmemb, unsigned size)
 	void __user *userptr = (void __force __user *)(uintptr_t)user;

 	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);
-	}
+	mem = vmemdup_user(userptr, size);
+	if (IS_ERR(mem))
+		return ERR_PTR(PTR_ERR(mem));

 	return mem;
 }
--
2.28.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-08-17  7:08 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-11 17:56 [PATCH] drm/nouveau/gem: Use vmemdup_user() rather than duplicating its implementation Markus Elfring
2020-08-11 17:56 ` Markus Elfring
2020-08-13 13:12 ` [PATCH] drm/nouveau/gem: fix err_cast.cocci warnings kernel test robot
2020-08-13 13:12   ` kernel test robot
2020-08-13 13:12   ` kernel test robot
2020-08-13 13:12   ` kernel test robot
2020-08-13 13:12 ` [PATCH] drm/nouveau/gem: Use vmemdup_user() rather than duplicating its implementation kernel test robot
2020-08-13 13:12   ` kernel test robot
2020-08-13 13:12   ` kernel test robot
2020-08-13 13:12   ` kernel test robot
2020-08-13 13:12   ` kernel test robot
     [not found]   ` <202008132104.mkULNh4R%lkp-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2020-08-14  7:09     ` [PATCH v2] " Markus Elfring
2020-08-14  7:09       ` Markus Elfring
2020-08-14  7:09       ` [Cocci] " Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.