diff mbox series

[v2] drm/nouveau/gem: Use vmemdup_user() rather than duplicating its implementation

Message ID f11df9ce-c49a-e172-47dd-5a0ab202ae81@web.de (mailing list archive)
State New, archived
Headers show
Series [v2] drm/nouveau/gem: Use vmemdup_user() rather than duplicating its implementation | expand

Commit Message

Markus Elfring Aug. 14, 2020, 7:09 a.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 14 Aug 2020 08:56:54 +0200

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

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

* See also:
  [PATCH] drm/nouveau/gem: fix err_cast.cocci warnings

* Simplify this function implementation further by omitting the local
  variable “mem” and extra error handling here.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/nouveau/nouveau_gem.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

--
2.28.0
diff mbox series

Patch

diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 81f111ad3f4f..536ad5e2cbe6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -583,21 +583,10 @@  u_free(void *addr)
 static inline void *
 u_memcpya(uint64_t user, unsigned nmemb, unsigned size)
 {
-	void *mem;
 	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);
-	}
-
-	return mem;
+	return vmemdup_user(userptr, size);
 }

 static int