Messages in this thread Patch in this message | | | From | Qing Wang <> | Subject | [PATCH] gpu: drm: nouveau: switch over to vmemdup_user() | Date | Mon, 18 Oct 2021 01:00:03 -0700 |
| |
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
Signed-off-by: Qing Wang <wangqing@vivo.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 8c2ecc2..3fc6959 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -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; } -- 2.7.4
| |