Re: [KJ] kmalloc to kzalloc patches for drivers/block [sane version]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Om Narasimhan wrote:
Comments incorporated
Changes kmalloc() calls succeeded by memset(,0,) to kzalloc()

Signed off by : Om Narasimhan <[email protected]>
drivers/block/cciss.c    |    4 +---
drivers/block/cpqarray.c |    7 ++-----
drivers/block/loop.c     |    3 +--
3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 2cd3391..a800a69 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -900,7 +900,7 @@ #if 0                /* 'buf_size' member is 16-bits
                return -EINVAL;
#endif
            if (iocommand.buf_size > 0) {
-                buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
+                buff = kzalloc(iocommand.buf_size, GFP_KERNEL);
                if (buff == NULL)
                    return -EFAULT;
            }
@@ -911,8 +911,6 @@ #endif
                    kfree(buff);
                    return -EFAULT;
                }
-            } else {
-                memset(buff, 0, iocommand.buf_size);

No.

            }
            if ((c = cmd_alloc(host, 0)) == NULL) {
                kfree(buff);
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 78082ed..34f8e96 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -424,7 +424,7 @@ static int __init cpqarray_register_ctlr
    hba[i]->cmd_pool = (cmdlist_t *)pci_alloc_consistent(
        hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t),
        &(hba[i]->cmd_pool_dhandle));
-    hba[i]->cmd_pool_bits = kmalloc(
+    hba[i]->cmd_pool_bits = kzalloc(
        ((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long),
        GFP_KERNEL);

kcalloc?

@@ -432,7 +432,6 @@ static int __init cpqarray_register_ctlr
            goto Enomem1;

    memset(hba[i]->cmd_pool, 0, NR_CMDS * sizeof(cmdlist_t));
-    memset(hba[i]->cmd_pool_bits, 0,
((NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG)*sizeof(unsigned long));

What's this? Wrapped? kcalloc?

    printk(KERN_INFO "cpqarray: Finding drives on %s",
        hba[i]->devname);

@@ -523,7 +522,6 @@ static int __init cpqarray_init_one( str
    i = alloc_cpqarray_hba();
    if( i < 0 )
        return (-1);
-    memset(hba[i], 0, sizeof(ctlr_info_t));
    sprintf(hba[i]->devname, "ida%d", i);
    hba[i]->ctlr = i;
    /* Initialize the pdev driver private data */
@@ -580,7 +578,7 @@ static int alloc_cpqarray_hba(void)

    for(i=0; i< MAX_CTLR; i++) {
        if (hba[i] == NULL) {
-            hba[i] = kmalloc(sizeof(ctlr_info_t), GFP_KERNEL);
+            hba[i] = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
            if(hba[i]==NULL) {
                printk(KERN_ERR "cpqarray: out of memory.\n");
                return (-1);
@@ -765,7 +763,6 @@ static int __init cpqarray_eisa_detect(v
            continue;
        }

-        memset(hba[ctlr], 0, sizeof(ctlr_info_t));
        hba[ctlr]->io_mem_addr = eisa[i];
        hba[ctlr]->io_mem_length = 0x7FF;
        if(!request_region(hba[ctlr]->io_mem_addr,
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 7b3b94d..91b48ef 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1260,10 +1260,9 @@ static int __init loop_init(void)
    if (register_blkdev(LOOP_MAJOR, "loop"))
        return -EIO;

-    loop_dev = kmalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
+    loop_dev = kzalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);

kcalloc?

regards,
--
http://www.fi.muni.cz/~xslaby/            Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8  22A0 32CC 55C3 39D4 7A7E
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux