Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759942Ab2HXQaT (ORCPT ); Fri, 24 Aug 2012 12:30:19 -0400 Received: from mail-vc0-f174.google.com ([209.85.220.174]:36818 "EHLO mail-vc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759913Ab2HXQaN (ORCPT ); Fri, 24 Aug 2012 12:30:13 -0400 MIME-Version: 1.0 In-Reply-To: <20120824152735.GA7897@localhost> References: <20120824152735.GA7897@localhost> Date: Fri, 24 Aug 2012 09:30:12 -0700 Message-ID: Subject: Re: [PATCH] megaraid_sas: combine kmalloc+memset into kzalloc From: adam radford To: Fengguang Wu Cc: James Bottomley , Neela Syam Kolli , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1818 Lines: 40 On Fri, Aug 24, 2012 at 8:27 AM, Fengguang Wu wrote: > Use kzalloc rather than kmalloc followed by memset with 0. > > Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci > > Signed-off-by: Fengguang Wu > --- > drivers/scsi/megaraid/megaraid_sas_fusion.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > --- linux.orig/drivers/scsi/megaraid/megaraid_sas_fusion.c 2012-06-07 05:39:57.418846382 +0800 > +++ linux/drivers/scsi/megaraid/megaraid_sas_fusion.c 2012-08-24 23:25:02.261560445 +0800 > @@ -461,8 +461,8 @@ megasas_alloc_cmds_fusion(struct megasas > * 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 " > @@ -470,9 +470,6 @@ megasas_alloc_cmds_fusion(struct megasas > 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), Acked-by: Adam Radford -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/