From: kbuild test robot <fengguang.wu@intel.com>
To: Sudarsana Reddy Kalluru <sudarsana.kalluru@qlogic.com>
Cc: kbuild-all@01.org, netdev@vger.kernel.org,
Yuval Mintz <Yuval.Mintz@qlogic.com>,
Ariel Elior <Ariel.Elior@qlogic.com>,
everest-linux-l2@qlogic.com, linux-kernel@vger.kernel.org
Subject: [PATCH] qed: fix kzalloc-simple.cocci warnings
Date: Thu, 1 Sep 2016 14:45:12 +0800 [thread overview]
Message-ID: <20160901064512.GA49421@lkp-sb04> (raw)
In-Reply-To: <201609011409.GGSqCknq%fengguang.wu@intel.com>
drivers/net/ethernet/qlogic/qed/qed_dcbx.c:1230:13-20: WARNING: kzalloc should be used for dcbx_info, instead of kmalloc/memset
drivers/net/ethernet/qlogic/qed/qed_dcbx.c:1192:13-20: WARNING: kzalloc should be used for dcbx_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: Sudarsana Reddy Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---
qed_dcbx.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
--- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
@@ -1189,13 +1189,12 @@ int qed_dcbx_get_config_params(struct qe
return 0;
}
- dcbx_info = kmalloc(sizeof(*dcbx_info), GFP_KERNEL);
+ dcbx_info = kzalloc(sizeof(*dcbx_info), GFP_KERNEL);
if (!dcbx_info) {
DP_ERR(p_hwfn, "Failed to allocate struct qed_dcbx_info\n");
return -ENOMEM;
}
- memset(dcbx_info, 0, sizeof(*dcbx_info));
rc = qed_dcbx_query_params(p_hwfn, dcbx_info, QED_DCBX_OPERATIONAL_MIB);
if (rc) {
kfree(dcbx_info);
@@ -1227,13 +1226,12 @@ static struct qed_dcbx_get *qed_dcbnl_ge
{
struct qed_dcbx_get *dcbx_info;
- dcbx_info = kmalloc(sizeof(*dcbx_info), GFP_KERNEL);
+ dcbx_info = kzalloc(sizeof(*dcbx_info), GFP_KERNEL);
if (!dcbx_info) {
DP_ERR(hwfn->cdev, "Failed to allocate memory for dcbx_info\n");
return NULL;
}
- memset(dcbx_info, 0, sizeof(*dcbx_info));
if (qed_dcbx_query_params(hwfn, dcbx_info, type)) {
kfree(dcbx_info);
return NULL;
next prev parent reply other threads:[~2016-09-01 6:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-01 6:45 [net:master 27/28] drivers/net/ethernet/qlogic/qed/qed_dcbx.c:1230:13-20: WARNING: kzalloc should be used for dcbx_info, instead of kmalloc/memset kbuild test robot
2016-09-01 6:45 ` kbuild test robot [this message]
2016-09-01 7:37 ` [PATCH] qed: fix kzalloc-simple.cocci warnings Yuval Mintz
2016-09-01 16:48 ` David Miller
2016-09-02 17:44 ` Joe Perches
2016-09-02 17:48 ` [PATCH] qed: Remove OOM messages Joe Perches
2016-09-04 8:18 ` Yuval Mintz
2016-09-04 20:28 ` David Miller
2016-09-04 21:22 ` Joe Perches
-- strict thread matches above, loose matches on Subject: below --
2017-04-21 0:20 [net:master 15/18] drivers/net/ethernet/qlogic/qed/qed_dcbx.c:1267:13-20: WARNING: kzalloc should be used for dcbx_info, instead of kmalloc/memset kbuild test robot
2017-04-21 0:20 ` [PATCH] qed: fix kzalloc-simple.cocci warnings kbuild test robot
2017-04-24 16:03 ` David Miller
[not found] <201509302130.SXWHwgAF%fengguang.wu@intel.com>
2015-09-30 13:03 ` [RFC v3 net-next 01/10] qed: Add module with basic common support Yuval Mintz
2015-09-30 13:33 ` [PATCH] qed: fix kzalloc-simple.cocci warnings kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160901064512.GA49421@lkp-sb04 \
--to=fengguang.wu@intel.com \
--cc=Ariel.Elior@qlogic.com \
--cc=Yuval.Mintz@qlogic.com \
--cc=everest-linux-l2@qlogic.com \
--cc=kbuild-all@01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sudarsana.kalluru@qlogic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).