Skip to contentSkip to conversation

drm: nouveau: use vmemdup_user instead of kvmalloc and copy_from_user

PATCH New Qing Wang 1 participant 1 message Dec 14, 2021

Subsystems (3)
lore
Share & tools
lore

Qing Wang

author
#0 lore raw

PATCH 1/1 drm: nouveau: use vmemdup_user instead of kvmalloc and copy_from_user

From: Wang Qing <[email protected]>

fix memdup_user.cocci warning:
nouveau_gem.c:630:7-15: WARNING opportunity for vmemdup_user

---
 drivers/gpu/drm/nouveau/nouveau_gem.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/gpu/drm/nouveau/nouveau_gem.c +1 -10
index 9416bee..befb864
@@ -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
Signature · 1 line
2.7.4