mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* + coda-use-vmemdup_user-to-replace-the-open-code.patch added to -mm tree
@ 2021-09-15  3:57 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2021-09-15  3:57 UTC (permalink / raw)
  To: alex.shi, jaharkes, jing.yangyang, mm-commits, tanxin.ctf,
	xiyuyang19, zealci


The patch titled
     Subject: coda: use vmemdup_user to replace the open code
has been added to the -mm tree.  Its filename is
     coda-use-vmemdup_user-to-replace-the-open-code.patch

This patch should soon appear at
    https://ozlabs.org/~akpm/mmots/broken-out/coda-use-vmemdup_user-to-replace-the-open-code.patch
and later at
    https://ozlabs.org/~akpm/mmotm/broken-out/coda-use-vmemdup_user-to-replace-the-open-code.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Jing Yangyang <jing.yangyang@zte.com.cn>
Subject: coda: use vmemdup_user to replace the open code

vmemdup_user is better than duplicating its implementation, So just
replace the open code.

./fs/coda/psdev.c:125:10-18:WARNING:opportunity for vmemdup_user

The issue is detected with the help of Coccinelle.

Link: https://lkml.kernel.org/r/20210908140308.18491-9-jaharkes@cs.cmu.edu
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Jing Yangyang <jing.yangyang@zte.com.cn>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
Cc: Alex Shi <alex.shi@linux.alibaba.com>
Cc: Xin Tan <tanxin.ctf@gmail.com>
Cc: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/coda/psdev.c |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

--- a/fs/coda/psdev.c~coda-use-vmemdup_user-to-replace-the-open-code
+++ a/fs/coda/psdev.c
@@ -122,14 +122,10 @@ static ssize_t coda_psdev_write(struct f
 				hdr.opcode, hdr.unique);
 		        nbytes = size;
 		}
-		dcbuf = kvmalloc(nbytes, GFP_KERNEL);
-		if (!dcbuf) {
-			retval = -ENOMEM;
-			goto out;
-		}
-		if (copy_from_user(dcbuf, buf, nbytes)) {
-			kvfree(dcbuf);
-			retval = -EFAULT;
+
+		dcbuf = vmemdup_user(buf, nbytes);
+		if (IS_ERR(dcbuf)) {
+			retval = PTR_ERR(dcbuf);
 			goto out;
 		}
 
_

Patches currently in -mm which might be from jing.yangyang@zte.com.cn are

coda-use-vmemdup_user-to-replace-the-open-code.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-15  3:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-15  3:57 + coda-use-vmemdup_user-to-replace-the-open-code.patch added to -mm tree akpm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).