[SCSI] megaraid_sas: combine kmalloc+memset into kzalloc
authorFengguang Wu <fengguang.wu@intel.com>
Fri, 24 Aug 2012 15:27:35 +0000 (23:27 +0800)
committerJames Bottomley <JBottomley@Parallels.com>
Mon, 24 Sep 2012 08:10:58 +0000 (12:10 +0400)
Use kzalloc rather than kmalloc followed by memset with 0.

Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Acked-by: Adam Radford <aradford@gmail.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/megaraid/megaraid_sas_fusion.c

index 788115b72b2292ee6868d3fa528108d3a3d9e279..ddf094e7d0acf8b628745389ee87d206da80e4c4 100644 (file)
@@ -462,8 +462,8 @@ megasas_alloc_cmds_fusion(struct megasas_instance *instance)
         * Allocate the dynamic array first and then allocate individual
         * commands.
         */
-       fusion->cmd_list = kmalloc(sizeof(struct megasas_cmd_fusion *)
-                                  *max_cmd, GFP_KERNEL);
+       fusion->cmd_list = kzalloc(sizeof(struct megasas_cmd_fusion *)
+                                  * max_cmd, GFP_KERNEL);
 
        if (!fusion->cmd_list) {
                printk(KERN_DEBUG "megasas: out of memory. Could not alloc "
@@ -471,9 +471,6 @@ megasas_alloc_cmds_fusion(struct megasas_instance *instance)
                goto fail_cmd_list;
        }
 
-       memset(fusion->cmd_list, 0, sizeof(struct megasas_cmd_fusion *)
-              *max_cmd);
-
        max_cmd = instance->max_fw_cmds;
        for (i = 0; i < max_cmd; i++) {
                fusion->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd_fusion),