summaryrefslogtreecommitdiffstats
path: root/fs/coda
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2019-07-16 19:28:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-07-16 22:23:23 -0400
commit4dc48193d748f0f0fbe37105a905466ff3a6ad50 (patch)
tree7547b1eff27892eef20e113d72ac5a7b4032ea40 /fs/coda
parent5e7c31dfe74703f428220384b2863525957cc160 (diff)
coda: get rid of CODA_ALLOC()
These days we have kvzalloc() so we can delete CODA_ALLOC(). I made a couple related changes in coda_psdev_write(). First, I added some error handling to avoid a NULL dereference if the allocation failed. Second, I used kvmalloc() instead of kvzalloc() because we copy over the memory on the next line so there is no need to zero it first. Link: http://lkml.kernel.org/r/e56010c822e7a7cbaa8a238cf82ad31c67eaa800.1558117389.git.jaharkes@cs.cmu.edu Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Colin Ian King <colin.king@canonical.com> Cc: David Howells <dhowells@redhat.com> Cc: Fabian Frederick <fabf@skynet.be> Cc: Mikko Rapeli <mikko.rapeli@iki.fi> Cc: Sam Protsenko <semen.protsenko@linaro.org> Cc: Yann Droneaud <ydroneaud@opteya.com> Cc: Zhouyang Jia <jiazhouyang09@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/coda')
-rw-r--r--fs/coda/coda_linux.h10
-rw-r--r--fs/coda/psdev.c6
-rw-r--r--fs/coda/upcall.c4
3 files changed, 7 insertions, 13 deletions
diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h
index 126155cadfa9..1ea9521e79d7 100644
--- a/fs/coda/coda_linux.h
+++ b/fs/coda/coda_linux.h
@@ -63,16 +63,6 @@ unsigned short coda_flags_to_cflags(unsigned short);
63void coda_sysctl_init(void); 63void coda_sysctl_init(void);
64void coda_sysctl_clean(void); 64void coda_sysctl_clean(void);
65 65
66#define CODA_ALLOC(ptr, cast, size) do { \
67 if (size < PAGE_SIZE) \
68 ptr = kzalloc((unsigned long) size, GFP_KERNEL); \
69 else \
70 ptr = (cast)vzalloc((unsigned long) size); \
71 if (!ptr) \
72 pr_warn("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
73} while (0)
74
75
76#define CODA_FREE(ptr, size) kvfree((ptr)) 66#define CODA_FREE(ptr, size) kvfree((ptr))
77 67
78/* inode to cnode access functions */ 68/* inode to cnode access functions */
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index ac130d469a3e..f74296acc59e 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -123,7 +123,11 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
123 hdr.opcode, hdr.unique); 123 hdr.opcode, hdr.unique);
124 nbytes = size; 124 nbytes = size;
125 } 125 }
126 CODA_ALLOC(dcbuf, union outputArgs *, nbytes); 126 dcbuf = kvmalloc(nbytes, GFP_KERNEL);
127 if (!dcbuf) {
128 retval = -ENOMEM;
129 goto out;
130 }
127 if (copy_from_user(dcbuf, buf, nbytes)) { 131 if (copy_from_user(dcbuf, buf, nbytes)) {
128 CODA_FREE(dcbuf, nbytes); 132 CODA_FREE(dcbuf, nbytes);
129 retval = -EFAULT; 133 retval = -EFAULT;
diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
index cf1e662681a5..b6ac5fc98189 100644
--- a/fs/coda/upcall.c
+++ b/fs/coda/upcall.c
@@ -46,7 +46,7 @@ static void *alloc_upcall(int opcode, int size)
46{ 46{
47 union inputArgs *inp; 47 union inputArgs *inp;
48 48
49 CODA_ALLOC(inp, union inputArgs *, size); 49 inp = kvzalloc(size, GFP_KERNEL);
50 if (!inp) 50 if (!inp)
51 return ERR_PTR(-ENOMEM); 51 return ERR_PTR(-ENOMEM);
52 52
@@ -743,7 +743,7 @@ static int coda_upcall(struct venus_comm *vcp,
743 sig_req = kmalloc(sizeof(struct upc_req), GFP_KERNEL); 743 sig_req = kmalloc(sizeof(struct upc_req), GFP_KERNEL);
744 if (!sig_req) goto exit; 744 if (!sig_req) goto exit;
745 745
746 CODA_ALLOC((sig_req->uc_data), char *, sizeof(struct coda_in_hdr)); 746 sig_req->uc_data = kvzalloc(sizeof(struct coda_in_hdr), GFP_KERNEL);
747 if (!sig_req->uc_data) { 747 if (!sig_req->uc_data) {
748 kfree(sig_req); 748 kfree(sig_req);
749 goto exit; 749 goto exit;