[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1614675899-88091-1-git-send-email-yang.lee@linux.alibaba.com>
Date: Tue, 2 Mar 2021 17:04:59 +0800
From: Yang Li <yang.lee@...ux.alibaba.com>
To: jaharkes@...cmu.edu
Cc: coda@...cmu.edu, codalist@...a.cs.cmu.edu,
linux-kernel@...r.kernel.org, Yang Li <yang.lee@...ux.alibaba.com>
Subject: [PATCH] coda: switch to vmemdup_user()
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@...ux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@...ux.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
Powered by blists - more mailing lists