[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1634544003-36775-1-git-send-email-wangqing@vivo.com>
Date: Mon, 18 Oct 2021 01:00:03 -0700
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: Qing Wang <wangqing@...o.com>
Subject: [PATCH] gpu: drm: nouveau: switch over to vmemdup_user()
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@...o.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
Powered by blists - more mailing lists