From mboxrd@z Thu Jan 1 00:00:00 1970 From: kbuild test robot Subject: [PATCH] qed: fix kzalloc-simple.cocci warnings Date: Wed, 30 Sep 2015 21:33:28 +0800 Message-ID: <20150930133328.GA193013@lkp-ib03> References: <201509302130.SXWHwgAF%fengguang.wu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kbuild-all@01.org, netdev@vger.kernel.org, Ariel.Elior@qlogic.com, Yuval.Mintz@qlogic.com To: Yuval Mintz Return-path: Received: from mga11.intel.com ([192.55.52.93]:62471 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752419AbbI3Ne3 (ORCPT ); Wed, 30 Sep 2015 09:34:29 -0400 Content-Disposition: inline In-Reply-To: <1443618217-18069-2-git-send-email-Yuval.Mintz@qlogic.com> Sender: netdev-owner@vger.kernel.org List-ID: drivers/net/ethernet/qlogic/qed/qed_int.c:644:30-37: WARNING: kzalloc should be used for p_hwfn -> hw_info . p_igu_info, instead of kmalloc/memset Use kzalloc rather than kmalloc 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/kzalloc-simple.cocci CC: Yuval Mintz Signed-off-by: Fengguang Wu --- qed_int.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/drivers/net/ethernet/qlogic/qed/qed_int.c +++ b/drivers/net/ethernet/qlogic/qed/qed_int.c @@ -641,13 +641,11 @@ int qed_int_igu_read_cam(struct qed_hwfn u16 sb_id; u16 prev_sb_id = 0xFF; - p_hwfn->hw_info.p_igu_info = kmalloc(sizeof(*p_igu_info), GFP_ATOMIC); + p_hwfn->hw_info.p_igu_info = kzalloc(sizeof(*p_igu_info), GFP_ATOMIC); if (!p_hwfn->hw_info.p_igu_info) return -ENOMEM; - memset(p_hwfn->hw_info.p_igu_info, 0, sizeof(*p_igu_info)); - p_igu_info = p_hwfn->hw_info.p_igu_info; /* Initialize base sb / sb cnt for PFs */