[PATCH] drm/nouveau: Use vmemdup_user()
Tian Tao
tiantao6 at hisilicon.com
Thu Nov 12 01:36:33 UTC 2020
Replace alloc and copy with vmemdup_user()
Signed-off-by: Tian Tao <tiantao6 at hisilicon.com>
---
drivers/gpu/drm/nouveau/nouveau_gem.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 787d05e..df986d9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -591,14 +591,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_CAST(mem);
return mem;
}
--
2.7.4
More information about the dri-devel
mailing list