qed: fix unnecessary call to memset cocci warnings
Subsystems (3)
PATCH 1/1 qed: fix unnecessary call to memset cocci warnings
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.")'
--- drivers/net/ethernet/qlogic/qed/qed_dcbx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/qlogic/qed/qed_dcbx.c +1 -2
@@ -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 ;
Signature · 1 line
1.9.1
David Miller
maintainerFrom: Vasyl Gomonovych <[email protected]>
Date: Wed, 15 Nov 2017 20:58:15 +0100
drivers/net/ethernet/qlogic/qed/qed_dcbx.c static struct qed_dcbx_get *qed_dcbnl_get_dcbx(struct qed_hwfn *hwfn, · line 1280
Quoted 6 lines
drivers/net/ethernet/qlogic/qed/qed_dcbx.c +1
-1@@ -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.
Sorry.
PATCH 1/1 qed: fix unnecessary call to memset cocci warnings
In reply to Vasyl GomonovychUse 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
--- drivers/net/ethernet/qlogic/qed/qed_dcbx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/qlogic/qed/qed_dcbx.c +1 -2
@@ -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 =kzalloc (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 ;
Signature · 1 line
1.9.1
Quoted 5 lines · Vasyl Gomonovych
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 fordcbx_info, instead of kmalloc/memset Generated by:scripts/coccinelle/api/alloc/kzalloc-simple.cocci
While this looks okay per se now, it would be good if you put version of the patch and add a changelog to it.
I think no need to resend this one, just for your information.
Quoted 25 lines
Signed-off-by Vasyl Gomonovych <[email protected]>--- drivers/net/ethernet/qlogic/qed/qed_dcbx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/ethernet/qlogic/qed/qed_dcbx.c +1
-3@@ -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 =kzalloc (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 ; --1.9.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
David Miller
maintainerFrom: Vasyl Gomonovych <[email protected]>
Date: Thu, 16 Nov 2017 23:04:08 +0100
Quoted 7 lines
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 fordcbx_info, instead of kmalloc/memset Generated by:scripts/coccinelle/api/alloc/kzalloc-simple.cocciSigned-off-by Vasyl Gomonovych <[email protected]>
This patch doesn't even apply.
It doesn't apply becouse of identical one qed: use kzalloc instead of kmalloc and memset.