From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> Date: Fri, 14 Aug 2020 08:56:54 +0200 * Reuse existing functionality from vmemdup_user() instead of keeping duplicate source code. Generated by: scripts/coccinelle/api/memdup_user.cocci * See also: [PATCH] drm/nouveau/gem: fix err_cast.cocci warnings * Simplify this function implementation further by omitting the local variable “mem” and extra error handling here. Reported-by: kernel test robot <lkp@xxxxxxxxx> Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> --- drivers/gpu/drm/nouveau/nouveau_gem.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 81f111ad3f4f..536ad5e2cbe6 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -583,21 +583,10 @@ u_free(void *addr) static inline void * u_memcpya(uint64_t user, unsigned nmemb, unsigned size) { - void *mem; void __user *userptr = (void __force __user *)(uintptr_t)user; 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.28.0 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel