cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] [PATCH v2] drm/nouveau/gem: Use vmemdup_user() rather than duplicating its implementation
       [not found] ` <202008132104.mkULNh4R%lkp@intel.com>
@ 2020-08-14  7:09   ` Markus Elfring
  0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2020-08-14  7:09 UTC (permalink / raw)
  To: kernel test robot, nouveau, dri-devel, Ben Skeggs, Daniel Vetter,
	David Airlie
  Cc: kbuild-all, kernel-janitors, LKML, Julia Lawall, Coccinelle

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(-)

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
--
2.28.0

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-14  8:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <12ebdcbe-8a8a-958a-af05-a0593d9756b2@web.de>
     [not found] ` <202008132104.mkULNh4R%lkp@intel.com>
2020-08-14  7:09   ` [Cocci] [PATCH v2] drm/nouveau/gem: Use vmemdup_user() rather than duplicating its implementation Markus Elfring

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).