* [PATCH] coda: switch to vmemdup_user()
@ 2021-03-02 9:04 Yang Li
0 siblings, 0 replies; only message in thread
From: Yang Li @ 2021-03-02 9:04 UTC (permalink / raw)
To: jaharkes; +Cc: coda, codalist, linux-kernel, Yang Li
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-03-02 9:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-02 9:04 [PATCH] coda: switch to vmemdup_user() Yang Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®