Use vmemdup_user() rather than duplicating its implementation. This patch fixes the following Coccinelle warning: ./drivers/gpu/drm/nouveau/nouveau_gem.c:630:7-15: WARNING opportunity for vmemdup_user Signed-off-by: Atul Raut <rauji.raut@xxxxxxxxx> --- drivers/gpu/drm/nouveau/nouveau_gem.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index ab9062e50977..a244b39df213 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -627,15 +627,10 @@ u_memcpya(uint64_t user, unsigned nmemb, unsigned size) size *= nmemb; - mem = kvmalloc(size, GFP_KERNEL); - if (!mem) + mem = vmemdup_user(userptr, size); + if (IS_ERR(mem)) return ERR_PTR(-ENOMEM); - if (copy_from_user(mem, userptr, size)) { - u_free(mem); - return ERR_PTR(-EFAULT); - } - return mem; } -- 2.34.1