Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752429AbdIVRZU (ORCPT ); Fri, 22 Sep 2017 13:25:20 -0400 Received: from mail-dm3nam03on0073.outbound.protection.outlook.com ([104.47.41.73]:9488 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752337AbdIVRZS (ORCPT ); Fri, 22 Sep 2017 13:25:18 -0400 From: "Madhani, Himanshu" To: Thomas Meyer CC: Dept-Eng QLA2xxx Upstream , "James E.J. Bottomley" , "Martin K . Petersen" , Linux SCSI Mailinglist , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 5/6] scsi: qla2xxx: Cocci spatch "pool_zalloc-simple" Thread-Topic: [PATCH 5/6] scsi: qla2xxx: Cocci spatch "pool_zalloc-simple" Thread-Index: AQHTMqI+8UJeONDNTE27pmBMZms8UaLBKj2A Date: Fri, 22 Sep 2017 17:25:16 +0000 Message-ID: References: <1505974468535-2047238743-0-diffsplit-thomas@m3y3r.de> <1505974468535-1220930483-5-diffsplit-thomas@m3y3r.de> In-Reply-To: <1505974468535-1220930483-5-diffsplit-thomas@m3y3r.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Himanshu.Madhani@cavium.com; x-originating-ip: [67.161.21.64] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR07MB3454;6:SEZZmnzu/ba4L+odKj7++XqMKQjsLml4Q3Zr70IU5iQfKP4qlI125vRKCgXwyGc12ff3t1GZV5wzs8xZPtS3J2gOpxhLKkjXdgULPRSvKDrqBkDa2hZaknSdLX0wI7Oc2s8Z5/rOLVSdtHgdAz6yE3XBUyO8rahs7xQLXvkDJf7m9a94zmjrlwzaeXP+/4YDdm4XnOlgWonqWvZV2gRjoFtBpfmuoxbTo14AHNDF2pXik329hiigQDoxVse0oad3BV99hNlthTlQBS4qF0wZUEoysA3HwexjWLdAjkArEIWFC249e7raRvAJet2oxPYn8lXiThIvePv0MU+b7r2Rog==;5:DyFB3ZuCyXzexAgG1atcqBbD0jU/fB0WBOWuaFMgY3WlyFDuEIZhHPxwOr2a874w+lF4fxAVfDb3LhOukrK3AHkHSGjg7vpEq79GEJVG9cnJ4uYUgWqiyRDfMBBg/Zq/3Bx3doyAT8JoiieqEEdiYA==;24:rwv2YoYA/hy2wOsg3IDhwJpmosgVElA1V7x4zhWWvPRreXx0J/Cvjwb+Bre6B5vioOC/llx3uaPIjLt9nZyoetyIJRljGTk/ItTnpAOR4Bc=;7:lp4XMTvqRnEYj9E4a+y0i6Wqt41fhy0eoKx5OtLdgWx9e1W9y4ZBfQS4PTRsB1TvkPFCDmnczg2D40iQKUs/Krn201sRY+9YKRv+lWwWTdebmLxlpoq3YV9Q4WIxkXru++HAnyyLEjvERhDcwVtWKg9o+8THEkZrN7mtnDL1lE8SfxeIKIff68HG6a/68ort6TON9ccHU89EySLgcD33IXr8PNhrakZ3O3QJsMb5XBA= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 81fb91ab-378a-4fd3-5ac5-08d501dee434 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:MWHPR07MB3454; x-ms-traffictypediagnostic: MWHPR07MB3454: x-exchange-antispam-report-test: UriScan:; x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123555025)(20161123558100)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:MWHPR07MB3454;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:MWHPR07MB3454; x-forefront-prvs: 0438F90F17 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(376002)(346002)(189002)(199003)(24454002)(377454003)(106356001)(8676002)(6512007)(36756003)(72206003)(6246003)(54356999)(83716003)(81166006)(8936002)(189998001)(76176999)(50986999)(478600001)(97736004)(6116002)(81156014)(33656002)(105586002)(2906002)(66066001)(68736007)(54906003)(25786009)(53936002)(4326008)(3660700001)(6436002)(82746002)(102836003)(3280700002)(3846002)(305945005)(2900100001)(101416001)(53546010)(7736002)(6486002)(5660300001)(6506006)(77096006)(316002)(14454004)(6916009)(99286003)(2950100002)(86362001)(229853002);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR07MB3454;H:MWHPR07MB3455.namprd07.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <73EFC56AC97E744FA968998E4FA5720A@namprd07.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Sep 2017 17:25:16.4078 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB3454 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v8MHPPdF025572 Content-Length: 6793 Lines: 193 > On Sep 20, 2017, at 11:15 PM, Thomas Meyer wrote: > > Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0. > Found by coccinelle spatch "api/alloc/pool_zalloc-simple.cocci" > > Signed-off-by: Thomas Meyer > --- > > diff -u -p a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c > --- a/drivers/scsi/qla2xxx/qla_bsg.c > +++ b/drivers/scsi/qla2xxx/qla_bsg.c > @@ -1116,14 +1116,13 @@ qla84xx_mgmt_cmd(struct bsg_job *bsg_job > return -EINVAL; > } > > - mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); > + mn = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); > if (!mn) { > ql_log(ql_log_warn, vha, 0x703c, > "DMA alloc failed for fw buffer.\n"); > return -ENOMEM; > } > > - memset(mn, 0, sizeof(struct access_chip_84xx)); > mn->entry_type = ACCESS_CHIP_IOCB_TYPE; > mn->entry_count = 1; > ql84_mgmt = (void *)bsg_request + sizeof(struct fc_bsg_request); > diff -u -p a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c > --- a/drivers/scsi/qla2xxx/qla_init.c > +++ b/drivers/scsi/qla2xxx/qla_init.c > @@ -812,13 +812,12 @@ int qla24xx_async_gpdb(struct scsi_qla_h > sp->gen2 = fcport->login_gen; > qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); > > - pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); > + pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); > if (pd == NULL) { > ql_log(ql_log_warn, vha, 0xd043, > "Failed to allocate port database structure.\n"); > goto done_free_sp; > } > - memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE)); > > mb = sp->u.iocb_cmd.u.mbx.out_mb; > mb[0] = MBC_GET_PORT_DATABASE; > diff -u -p a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c > --- a/drivers/scsi/qla2xxx/qla_mbx.c > +++ b/drivers/scsi/qla2xxx/qla_mbx.c > @@ -1782,13 +1782,12 @@ qla2x00_get_port_database(scsi_qla_host_ > "Entered %s.\n", __func__); > > pd24 = NULL; > - pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); > + pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); > if (pd == NULL) { > ql_log(ql_log_warn, vha, 0x1050, > "Failed to allocate port database structure.\n"); > return QLA_MEMORY_ALLOC_FAILED; > } > - memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE)); > > mcp->mb[0] = MBC_GET_PORT_DATABASE; > if (opt != 0 && !IS_FWI2_CAPABLE(ha)) > @@ -2255,13 +2254,12 @@ qla24xx_login_fabric(scsi_qla_host_t *vh > else > req = ha->req_q_map[0]; > > - lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); > + lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); > if (lg == NULL) { > ql_log(ql_log_warn, vha, 0x1062, > "Failed to allocate login IOCB.\n"); > return QLA_MEMORY_ALLOC_FAILED; > } > - memset(lg, 0, sizeof(struct logio_entry_24xx)); > > lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; > lg->entry_count = 1; > @@ -2525,13 +2523,12 @@ qla24xx_fabric_logout(scsi_qla_host_t *v > ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106d, > "Entered %s.\n", __func__); > > - lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); > + lg = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma); > if (lg == NULL) { > ql_log(ql_log_warn, vha, 0x106e, > "Failed to allocate logout IOCB.\n"); > return QLA_MEMORY_ALLOC_FAILED; > } > - memset(lg, 0, sizeof(struct logio_entry_24xx)); > > req = vha->req; > lg->entry_type = LOGINOUT_PORT_IOCB_TYPE; > @@ -2820,13 +2817,12 @@ qla2x00_get_fcal_position_map(scsi_qla_h > ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x107f, > "Entered %s.\n", __func__); > > - pmap = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma); > + pmap = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pmap_dma); > if (pmap == NULL) { > ql_log(ql_log_warn, vha, 0x1080, > "Memory alloc failed.\n"); > return QLA_MEMORY_ALLOC_FAILED; > } > - memset(pmap, 0, FCAL_MAP_SIZE); > > mcp->mb[0] = MBC_GET_FC_AL_POSITION_MAP; > mcp->mb[2] = MSW(pmap_dma); > @@ -3014,13 +3010,12 @@ qla24xx_abort_command(srb_t *sp) > return QLA_FUNCTION_FAILED; > } > > - abt = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma); > + abt = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &abt_dma); > if (abt == NULL) { > ql_log(ql_log_warn, vha, 0x108d, > "Failed to allocate abort IOCB.\n"); > return QLA_MEMORY_ALLOC_FAILED; > } > - memset(abt, 0, sizeof(struct abort_entry_24xx)); > > abt->entry_type = ABORT_IOCB_TYPE; > abt->entry_count = 1; > @@ -3098,13 +3093,12 @@ __qla24xx_issue_tmf(char *name, uint32_t > rsp = req->rsp; > } > > - tsk = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma); > + tsk = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &tsk_dma); > if (tsk == NULL) { > ql_log(ql_log_warn, vha, 0x1093, > "Failed to allocate task management IOCB.\n"); > return QLA_MEMORY_ALLOC_FAILED; > } > - memset(tsk, 0, sizeof(struct tsk_mgmt_cmd)); > > tsk->p.tsk.entry_type = TSK_MGMT_IOCB_TYPE; > tsk->p.tsk.entry_count = 1; > @@ -3856,14 +3850,13 @@ qla24xx_modify_vp_config(scsi_qla_host_t > ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10bb, > "Entered %s.\n", __func__); > > - vpmod = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma); > + vpmod = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &vpmod_dma); > if (!vpmod) { > ql_log(ql_log_warn, vha, 0x10bc, > "Failed to allocate modify VP IOCB.\n"); > return QLA_MEMORY_ALLOC_FAILED; > } > > - memset(vpmod, 0, sizeof(struct vp_config_entry_24xx)); > vpmod->entry_type = VP_CONFIG_IOCB_TYPE; > vpmod->entry_count = 1; > vpmod->command = VCT_COMMAND_MOD_ENABLE_VPS; > @@ -3934,13 +3927,12 @@ qla24xx_control_vp(scsi_qla_host_t *vha, > if (vp_index == 0 || vp_index >= ha->max_npiv_vports) > return QLA_PARAMETER_ERROR; > > - vce = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma); > + vce = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma); > if (!vce) { > ql_log(ql_log_warn, vha, 0x10c2, > "Failed to allocate VP control IOCB.\n"); > return QLA_MEMORY_ALLOC_FAILED; > } > - memset(vce, 0, sizeof(struct vp_ctrl_entry_24xx)); > > vce->entry_type = VP_CTRL_IOCB_TYPE; > vce->entry_count = 1; > @@ -6025,13 +6017,12 @@ int qla24xx_gpdb_wait(struct scsi_qla_ho > if (!vha->hw->flags.fw_started) > goto done; > > - pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); > + pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); > if (pd == NULL) { > ql_log(ql_log_warn, vha, 0xd047, > "Failed to allocate port database structure.\n"); > goto done_free_sp; > } > - memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE)); > > memset(&mc, 0, sizeof(mc)); > mc.mb[0] = MBC_GET_PORT_DATABASE; Looks good. Acked-by: Himanshu Madhani Thanks, - Himanshu