]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
coda: get rid of CODA_ALLOC()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 16 Jul 2019 23:28:38 +0000 (16:28 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 17 Jul 2019 02:23:23 +0000 (19:23 -0700)
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>
fs/coda/coda_linux.h
fs/coda/psdev.c
fs/coda/upcall.c

index 126155cadfa93c1c0eed8ff4849528a2407f9546..1ea9521e79d70ee700cffa7db4a7fd25bd6c649e 100644 (file)
@@ -63,16 +63,6 @@ unsigned short coda_flags_to_cflags(unsigned short);
 void coda_sysctl_init(void);
 void coda_sysctl_clean(void);
 
-#define CODA_ALLOC(ptr, cast, size) do { \
-    if (size < PAGE_SIZE) \
-        ptr = kzalloc((unsigned long) size, GFP_KERNEL); \
-    else \
-        ptr = (cast)vzalloc((unsigned long) size); \
-    if (!ptr) \
-       pr_warn("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
-} while (0)
-
-
 #define CODA_FREE(ptr, size) kvfree((ptr))
 
 /* inode to cnode access functions */
index ac130d469a3e20b5f8db5c737b5146e27528c06c..f74296acc59e0b095f7f60fa2077ec541573b684 100644 (file)
@@ -123,7 +123,11 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
                                hdr.opcode, hdr.unique);
                        nbytes = size;
                }
-               CODA_ALLOC(dcbuf, union outputArgs *, nbytes);
+               dcbuf = kvmalloc(nbytes, GFP_KERNEL);
+               if (!dcbuf) {
+                       retval = -ENOMEM;
+                       goto out;
+               }
                if (copy_from_user(dcbuf, buf, nbytes)) {
                        CODA_FREE(dcbuf, nbytes);
                        retval = -EFAULT;
index cf1e662681a5d128cef7f9c2735570a7a46123da..b6ac5fc98189d4eebacab47221bcebee04c82846 100644 (file)
@@ -46,7 +46,7 @@ static void *alloc_upcall(int opcode, int size)
 {
        union inputArgs *inp;
 
-       CODA_ALLOC(inp, union inputArgs *, size);
+       inp = kvzalloc(size, GFP_KERNEL);
         if (!inp)
                return ERR_PTR(-ENOMEM);
 
@@ -743,7 +743,7 @@ static int coda_upcall(struct venus_comm *vcp,
        sig_req = kmalloc(sizeof(struct upc_req), GFP_KERNEL);
        if (!sig_req) goto exit;
 
-       CODA_ALLOC((sig_req->uc_data), char *, sizeof(struct coda_in_hdr));
+       sig_req->uc_data = kvzalloc(sizeof(struct coda_in_hdr), GFP_KERNEL);
        if (!sig_req->uc_data) {
                kfree(sig_req);
                goto exit;