Nouveau Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring-S0/GAf8tV78@public.gmane.org>
To: kernel test robot <lkp-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	Ben Skeggs <bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Daniel Vetter <daniel-/w4YWyX8dFk@public.gmane.org>,
	David Airlie <airlied-cv59FeDIM0c@public.gmane.org>
Cc: kbuild-all-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Denis Efremov <efremov-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>,
	Julia Lawall <Julia.Lawall-L2FTfq7BK8M@public.gmane.org>,
	Coccinelle <cocci-/FJkirnvOdkvYVN+rsErww@public.gmane.org>
Subject: [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-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
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-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 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

      parent reply	other threads:[~2020-08-14  7:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-11 17:56 [PATCH] drm/nouveau/gem: Use vmemdup_user() rather than duplicating its implementation Markus Elfring
2020-08-13 13:12 ` [PATCH] drm/nouveau/gem: fix err_cast.cocci warnings kernel test robot
     [not found] ` <12ebdcbe-8a8a-958a-af05-a0593d9756b2-S0/GAf8tV78@public.gmane.org>
2020-08-13 13:12   ` [PATCH] drm/nouveau/gem: Use vmemdup_user() rather than duplicating its implementation kernel test robot
     [not found]     ` <202008132104.mkULNh4R%lkp-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2020-08-14  7:09       ` Markus Elfring [this message]

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-s0/gaf8tv78@public.gmane.org \
    --cc=Julia.Lawall-L2FTfq7BK8M@public.gmane.org \
    --cc=airlied-cv59FeDIM0c@public.gmane.org \
    --cc=bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=cocci-/FJkirnvOdkvYVN+rsErww@public.gmane.org \
    --cc=daniel-/w4YWyX8dFk@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=efremov-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org \
    --cc=kbuild-all-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org \
    --cc=kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lkp-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.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