Skip to content

Commit

Permalink
[SCSI] megaraid_sas: combine kmalloc+memset into kzalloc
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Fengguang Wu authored and James Bottomley committed Sep 24, 2012
1 parent 9728686 commit 7731e6b
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/scsi/megaraid/megaraid_sas_fusion.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,18 +462,15 @@ 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 "
"memory for cmd_list_fusion\n");
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),
Expand Down

0 comments on commit 7731e6b

Please sign in to comment.