From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============5395732462642073680==" MIME-Version: 1.0 From: kbuild test robot Subject: [PATCH] elx: efct: fix zalloc-simple.cocci warnings Date: Sun, 12 Apr 2020 15:22:55 +0800 Message-ID: <20200412072255.GA18961@9dbb232d854f> In-Reply-To: <202004121504.E6ItoFUo%lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============5395732462642073680== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org In-Reply-To: <20200412033303.29574-32-jsmart2021@gmail.com> References: <20200412033303.29574-32-jsmart2021@gmail.com> TO: James Smart CC: linux-scsi(a)vger.kernel.org CC: dwagner(a)suse.de, maier(a)linux.ibm.com, bvanassche(a)acm.org, herbszt= (a)gmx.de, natechancellor(a)gmail.com, rdunlap(a)infradead.org, hare(a)suse= .de, James Smart , Ram Vegesna From: kbuild test robot drivers/scsi/elx/efct/efct_lio.c:265:22-29: WARNING: kzalloc should be used= for filp -> private_data, instead of kmalloc/memset drivers/scsi/elx/efct/efct_lio.c:303:22-29: WARNING: kzalloc should be used= for filp -> private_data, instead of kmalloc/memset drivers/scsi/elx/efct/efct_lio.c:1462:11-18: WARNING: kzalloc should be use= d for wq_data, instead of kmalloc/memset Use zeroing allocator rather than allocator followed by memset with 0 This considers some simple cases that are common and easy to validate Note in particular that there are no ...s in the rule, so all of the matched code has to be contiguous Generated by: scripts/coccinelle/api/alloc/zalloc-simple.cocci CC: James Smart Signed-off-by: kbuild test robot --- url: https://github.com/0day-ci/linux/commits/James-Smart/efct-Broadcom-= Emulex-FC-Target-driver/20200412-114125 base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-ne= xt :::::: branch date: 4 hours ago :::::: commit date: 4 hours ago efct_lio.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) --- a/drivers/scsi/elx/efct/efct_lio.c +++ b/drivers/scsi/elx/efct/efct_lio.c @@ -262,11 +262,10 @@ static int efct_debugfs_session_open(str return EFC_SUCCESS; } = - filp->private_data =3D kmalloc(size, GFP_KERNEL); + filp->private_data =3D kzalloc(size, GFP_KERNEL); if (!filp->private_data) return -ENOMEM; = - memset(filp->private_data, 0, size); efct_lio_tgt_session_data(sport->efct, sport->wwpn, filp->private_data, size); return EFC_SUCCESS; @@ -300,11 +299,10 @@ static int efct_npiv_debugfs_session_ope return EFC_SUCCESS; } = - filp->private_data =3D kmalloc(size, GFP_KERNEL); + filp->private_data =3D kzalloc(size, GFP_KERNEL); if (!filp->private_data) return -ENOMEM; = - memset(filp->private_data, 0, size); efct_lio_tgt_session_data(sport->efct, sport->npiv_wwpn, filp->private_data, size); return EFC_SUCCESS; @@ -1459,11 +1457,10 @@ int efct_scsi_del_initiator(struct efc * if (reason =3D=3D EFCT_SCSI_INITIATOR_MISSING) return EFCT_SCSI_CALL_COMPLETE; = - wq_data =3D kmalloc(sizeof(*wq_data), GFP_ATOMIC); + wq_data =3D kzalloc(sizeof(*wq_data), GFP_ATOMIC); if (!wq_data) return EFCT_SCSI_CALL_COMPLETE; = - memset(wq_data, 0, sizeof(*wq_data)); wq_data->ptr =3D node; wq_data->efct =3D efct; INIT_WORK(&wq_data->work, efct_lio_remove_session); --===============5395732462642073680==--