From: Markus Elfring <Markus.Elfring@web.de>
To: kernel test robot <lkp@intel.com>,
nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
Ben Skeggs <bskeggs@redhat.com>, Daniel Vetter <daniel@ffwll.ch>,
David Airlie <airlied@linux.ie>
Cc: kbuild-all@lists.01.org, kernel-janitors@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
Julia Lawall <Julia.Lawall@lip6.fr>,
Coccinelle <cocci@systeme.lip6.fr>
Subject: [Cocci] [PATCH v2] drm/nouveau/gem: Use vmemdup_user() rather than duplicating its implementation
Date: Fri, 14 Aug 2020 09:09:34 +0200 [thread overview]
Message-ID: <f11df9ce-c49a-e172-47dd-5a0ab202ae81@web.de> (raw)
In-Reply-To: <202008132104.mkULNh4R%lkp@intel.com>
From: Markus Elfring <elfring@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@intel.com>
Signed-off-by: Markus Elfring <elfring@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
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
parent reply other threads:[~2020-08-14 8:05 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <202008132104.mkULNh4R%lkp@intel.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f11df9ce-c49a-e172-47dd-5a0ab202ae81@web.de \
--to=markus.elfring@web.de \
--cc=Julia.Lawall@lip6.fr \
--cc=airlied@linux.ie \
--cc=bskeggs@redhat.com \
--cc=cocci@systeme.lip6.fr \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kbuild-all@lists.01.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=nouveau@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox