Qing Wang
2021-Dec-14 12:17 UTC
[Nouveau] [PATCH] drm: nouveau: use vmemdup_user instead of kvmalloc and copy_from_user
From: Wang Qing <wangqing at vivo.com> fix memdup_user.cocci warning: nouveau_gem.c:630:7-15: WARNING opportunity for vmemdup_user Signed-off-by: Wang Qing <wangqing at vivo.com> --- drivers/gpu/drm/nouveau/nouveau_gem.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 9416bee..befb864 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -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 -- 2.7.4