[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1639484266-75733-1-git-send-email-wangqing@vivo.com>
Date: Tue, 14 Dec 2021 04:17:46 -0800
From: Qing Wang <wangqing@...o.com>
To: Ben Skeggs <bskeggs@...hat.com>, David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
dri-devel@...ts.freedesktop.org, nouveau@...ts.freedesktop.org,
linux-kernel@...r.kernel.org
Cc: Wang Qing <wangqing@...o.com>
Subject: [PATCH] drm: nouveau: use vmemdup_user instead of kvmalloc and copy_from_user
From: Wang Qing <wangqing@...o.com>
fix memdup_user.cocci warning:
nouveau_gem.c:630:7-15: WARNING opportunity for vmemdup_user
Signed-off-by: Wang Qing <wangqing@...o.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
Powered by blists - more mailing lists