Skip to contentSkip to conversation

gpu: drm: nouveau: switch over to vmemdup_user()

PATCH New Qing Wang 1 participant 1 message Oct 18, 2021

Subsystems (3)
lore
Share & tools
lore

Qing Wang

author
#0 lore raw

PATCH 1/1 gpu: drm: nouveau: switch over to vmemdup_user()

This patch fixes the following Coccinelle warning:

drivers/gpu/drm/nouveau/nouveau_gem.c:630: WARNING opportunity for vmemdup_user

Use vmemdup_user rather than duplicating its implementation This is a little bit restricted to reduce false positives

---
 drivers/gpu/drm/nouveau/nouveau_gem.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/gpu/drm/nouveau/nouveau_gem.c +3 -8
index 8c2ecc2..3fc6959
@@ -627,14 +627,9 @@ 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);
-	}
+	mem = vmemdup_user(userptr, size);
+	if (IS_ERR(mem))
+		return ERR_PTR(PTR_ERR(mem));
 
 	return mem;
 }
Signature · 1 line
2.7.4