[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1607044999-47666-7-git-send-email-tiantao6@hisilicon.com>
Date: Fri, 4 Dec 2020 09:23:12 +0800
From: Tian Tao <tiantao6@...ilicon.com>
To: <airlied@...ux.ie>, <daniel@...ll.ch>, <tzimmermann@...e.de>,
<kraxel@...hat.com>, <alexander.deucher@....com>,
<tglx@...utronix.de>, <dri-devel@...ts.freedesktop.org>,
<xinliang.liu@...aro.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH] drm/nouveau: Use vmemdup_user()
Replace alloc and copy with vmemdup_user()
Signed-off-by: Tian Tao <tiantao6@...ilicon.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 787d05e..df986d9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -591,14 +591,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_CAST(mem);
return mem;
}
--
2.7.4
Powered by blists - more mailing lists