Markus Elfring
2020-Aug-11 17:56 UTC
[Nouveau] [PATCH] drm/nouveau/gem: Use vmemdup_user() rather than duplicating its implementation
From: Markus Elfring <elfring at users.sourceforge.net> Date: Tue, 11 Aug 2020 19:25:22 +0200 Reuse existing functionality from vmemdup_user() instead of keeping duplicate source code. Generated by: scripts/coccinelle/api/memdup_user.cocci Signed-off-by: Markus Elfring <elfring at users.sourceforge.net> --- drivers/gpu/drm/nouveau/nouveau_gem.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 81f111ad3f4f..7ef6221408af 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -587,15 +587,9 @@ u_memcpya(uint64_t user, unsigned nmemb, unsigned size) 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); - } + mem = vmemdup_user(userptr, size); + if (IS_ERR(mem)) + return ERR_PTR(PTR_ERR(mem)); return mem; } -- 2.28.0
kernel test robot
2020-Aug-13 13:12 UTC
[Nouveau] [PATCH] drm/nouveau/gem: Use vmemdup_user() rather than duplicating its implementation
Hi Markus, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on drm-intel/for-linux-next] [also build test WARNING on drm-tip/drm-tip tegra-drm/drm/tegra/for-next linus/master drm/drm-next drm-exynos/exynos-drm-next v5.8 next-20200812] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Markus-Elfring/drm-nouveau-gem-Use-vmemdup_user-rather-than-duplicating-its-implementation/20200812-150757 base: git://anongit.freedesktop.org/drm-intel for-linux-next config: x86_64-randconfig-c002-20200811 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp at intel.com> coccinelle warnings: (new ones prefixed by >>)>> drivers/gpu/drm/nouveau/nouveau_gem.c:589:9-16: WARNING: ERR_CAST can be used with memPlease review and possibly fold the followup patch. --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all at lists.01.org -------------- next part -------------- A non-text attachment was scrubbed... Name: .config.gz Type: application/gzip Size: 34067 bytes Desc: not available URL: <https://lists.freedesktop.org/archives/nouveau/attachments/20200813/5c544fec/attachment-0001.gz>
kernel test robot
2020-Aug-13 13:12 UTC
[Nouveau] [PATCH] drm/nouveau/gem: fix err_cast.cocci warnings
From: kernel test robot <lkp at intel.com> drivers/gpu/drm/nouveau/nouveau_gem.c:589:9-16: WARNING: ERR_CAST can be used with mem Use ERR_CAST inlined function instead of ERR_PTR(PTR_ERR(...)) Generated by: scripts/coccinelle/api/err_cast.cocci CC: Markus Elfring <elfring at users.sourceforge.net> Signed-off-by: kernel test robot <lkp at intel.com> --- url: https://github.com/0day-ci/linux/commits/Markus-Elfring/drm-nouveau-gem-Use-vmemdup_user-rather-than-duplicating-its-implementation/20200812-150757 base: git://anongit.freedesktop.org/drm-intel for-linux-next nouveau_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -586,7 +586,7 @@ u_memcpya(uint64_t user, unsigned nmemb, size *= nmemb; mem = vmemdup_user(userptr, size); if (IS_ERR(mem)) - return ERR_PTR(PTR_ERR(mem)); + return ERR_CAST(mem); return mem; }
Markus Elfring
2020-Aug-14 07:09 UTC
[Nouveau] [PATCH v2] drm/nouveau/gem: Use vmemdup_user() rather than duplicating its implementation
From: Markus Elfring <elfring at users.sourceforge.net> 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 at intel.com> Signed-off-by: Markus Elfring <elfring at users.sourceforge.net> --- 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
Reasonably Related Threads
- [PATCH] drm/nouveau/gem: Use vmemdup_user() rather than duplicating its implementation
- [PATCH] drm/nouveau: Use vmemdup_user()
- [PATCH V2 4/6] vhost_vdpa: implement IRQ offloading in vhost_vdpa
- [PATCH] virtio_ring: use alloc_pages_node for NUMA-aware allocation
- [PATCH 6/8] powerpc/pseries: implement paravirt qspinlocks for SPLPAR