From: Yang Li <yang.lee@linux.alibaba.com>
To: jaharkes@cs.cmu.edu
Cc: coda@cs.cmu.edu, codalist@coda.cs.cmu.edu,
linux-kernel@vger.kernel.org,
Yang Li <yang.lee@linux.alibaba.com>
Subject: [PATCH] coda: switch to vmemdup_user()
Date: Tue, 2 Mar 2021 17:04:59 +0800 [thread overview]
Message-ID: <1614675899-88091-1-git-send-email-yang.lee@linux.alibaba.com> (raw)
Replace opencoded alloc and copy with vmemdup_user()
fixed the following coccicheck:
./fs/coda/psdev.c:125:10-18: WARNING opportunity for vmemdup_user
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
---
fs/coda/psdev.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 240669f..8d38e92 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -122,14 +122,9 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
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)) {
+ r = PTR_ERR(dcbuf);
goto out;
}
--
1.8.3.1
reply other threads:[~2021-03-02 9:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1614675899-88091-1-git-send-email-yang.lee@linux.alibaba.com \
--to=yang.lee@linux.alibaba.com \
--cc=coda@cs.cmu.edu \
--cc=codalist@coda.cs.cmu.edu \
--cc=jaharkes@cs.cmu.edu \
--cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).