diff mbox series

qed: fix unnecessary call to memset cocci warnings

Message ID 1510775895-16258-1-git-send-email-gomonovych@gmail.com
State Rejected, archived
Delegated to: David Miller
Headers show
Series qed: fix unnecessary call to memset cocci warnings | expand

Commit Message

Vasyl Gomonovych Nov. 15, 2017, 7:58 p.m. UTC
Use kzalloc rather than kmalloc followed by memset with 0
drivers/net/ethernet/qlogic/qed/qed_dcbx.c:1280:13-20: WARNING:
kzalloc should be used for dcbx_info, instead of kmalloc/memset
Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

Originally was fixed in:
'commit 561ed23331df ("qed: fix kzalloc-simple.cocci warnings")'
But later warning was introduced in:
'commit 62289ba27558 ("qed: Fix possible system hang in the
dcbnl-getdcbx() path.")'

Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
---
 drivers/net/ethernet/qlogic/qed/qed_dcbx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

David Miller Nov. 16, 2017, 1:37 a.m. UTC | #1
From: Vasyl Gomonovych <gomonovych@gmail.com>
Date: Wed, 15 Nov 2017 20:58:15 +0100

> @@ -1277,11 +1277,10 @@ static struct qed_dcbx_get *qed_dcbnl_get_dcbx(struct qed_hwfn *hwfn,
>  {
>  	struct qed_dcbx_get *dcbx_info;
>  
> -	dcbx_info = kmalloc(sizeof(*dcbx_info), GFP_ATOMIC);
> +	dcbx_info = kzmalloc(sizeof(*dcbx_info), GFP_ATOMIC);

Thanks for not even compile testing your patch.
Vasyl Gomonovych Nov. 16, 2017, 9:35 p.m. UTC | #2
Sorry.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
index 8f6ccc0c39e5..9a1bd996a640 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
@@ -1277,11 +1277,10 @@  static struct qed_dcbx_get *qed_dcbnl_get_dcbx(struct qed_hwfn *hwfn,
 {
 	struct qed_dcbx_get *dcbx_info;
 
-	dcbx_info = kmalloc(sizeof(*dcbx_info), GFP_ATOMIC);
+	dcbx_info = kzmalloc(sizeof(*dcbx_info), GFP_ATOMIC);
 	if (!dcbx_info)
 		return NULL;
 
-	memset(dcbx_info, 0, sizeof(*dcbx_info));
 	if (qed_dcbx_query_params(hwfn, dcbx_info, type)) {
 		kfree(dcbx_info);
 		return NULL;