* [PATCH] qed: fix unnecessary call to memset cocci warnings
@ 2017-11-15 19:58 Vasyl Gomonovych
2017-11-16 1:37 ` David Miller
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Vasyl Gomonovych @ 2017-11-15 19:58 UTC (permalink / raw)
To: gomonovych, Ariel.Elior, everest-linux-l2, netdev; +Cc: linux-kernel
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(-)
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;
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] qed: fix unnecessary call to memset cocci warnings
2017-11-15 19:58 [PATCH] qed: fix unnecessary call to memset cocci warnings Vasyl Gomonovych
@ 2017-11-16 1:37 ` David Miller
2017-11-16 21:35 ` Vasyl Gomonovych
2017-11-16 22:04 ` Vasyl Gomonovych
2 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2017-11-16 1:37 UTC (permalink / raw)
To: gomonovych; +Cc: Ariel.Elior, everest-linux-l2, netdev, linux-kernel
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] qed: fix unnecessary call to memset cocci warnings
2017-11-15 19:58 [PATCH] qed: fix unnecessary call to memset cocci warnings Vasyl Gomonovych
2017-11-16 1:37 ` David Miller
@ 2017-11-16 21:35 ` Vasyl Gomonovych
2017-11-16 22:04 ` Vasyl Gomonovych
2 siblings, 0 replies; 7+ messages in thread
From: Vasyl Gomonovych @ 2017-11-16 21:35 UTC (permalink / raw)
To: davem; +Cc: Ariel.Elior, everest-linux-l2, netdev, linux-kernel,
Vasyl Gomonovych
Sorry.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] qed: fix unnecessary call to memset cocci warnings
2017-11-15 19:58 [PATCH] qed: fix unnecessary call to memset cocci warnings Vasyl Gomonovych
2017-11-16 1:37 ` David Miller
2017-11-16 21:35 ` Vasyl Gomonovych
@ 2017-11-16 22:04 ` Vasyl Gomonovych
2017-11-17 15:59 ` Andy Shevchenko
` (2 more replies)
2 siblings, 3 replies; 7+ messages in thread
From: Vasyl Gomonovych @ 2017-11-16 22:04 UTC (permalink / raw)
To: davem; +Cc: Ariel.Elior, everest-linux-l2, netdev, linux-kernel,
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 for dcbx_info, instead of kmalloc/memset
Generated by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
---
drivers/net/ethernet/qlogic/qed/qed_dcbx.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
index 8f6ccc0c39e5..cc9e0dfcee48 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 = 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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] qed: fix unnecessary call to memset cocci warnings
2017-11-16 22:04 ` Vasyl Gomonovych
@ 2017-11-17 15:59 ` Andy Shevchenko
2017-11-18 1:31 ` David Miller
2017-11-20 21:31 ` Vasyl Gomonovych
2 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2017-11-17 15:59 UTC (permalink / raw)
To: Vasyl Gomonovych
Cc: David S. Miller, Elior, Ariel, everest-linux-l2, netdev,
linux-kernel@vger.kernel.org
On Fri, Nov 17, 2017 at 12:04 AM, Vasyl Gomonovych <gomonovych@gmail.com> wrote:
> 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
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.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
> ---
> drivers/net/ethernet/qlogic/qed/qed_dcbx.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
> index 8f6ccc0c39e5..cc9e0dfcee48 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 = 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
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] qed: fix unnecessary call to memset cocci warnings
2017-11-16 22:04 ` Vasyl Gomonovych
2017-11-17 15:59 ` Andy Shevchenko
@ 2017-11-18 1:31 ` David Miller
2017-11-20 21:31 ` Vasyl Gomonovych
2 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2017-11-18 1:31 UTC (permalink / raw)
To: gomonovych; +Cc: Ariel.Elior, everest-linux-l2, netdev, linux-kernel
From: Vasyl Gomonovych <gomonovych@gmail.com>
Date: Thu, 16 Nov 2017 23:04:08 +0100
> 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
>
> Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
This patch doesn't even apply.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] qed: fix unnecessary call to memset cocci warnings
2017-11-16 22:04 ` Vasyl Gomonovych
2017-11-17 15:59 ` Andy Shevchenko
2017-11-18 1:31 ` David Miller
@ 2017-11-20 21:31 ` Vasyl Gomonovych
2 siblings, 0 replies; 7+ messages in thread
From: Vasyl Gomonovych @ 2017-11-20 21:31 UTC (permalink / raw)
To: davem; +Cc: Ariel.Elior, everest-linux-l2, netdev, linux-kernel,
Vasyl Gomonovych
It doesn't apply becouse of identical one qed: use kzalloc instead of kmalloc and memset.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-11-20 21:31 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-15 19:58 [PATCH] qed: fix unnecessary call to memset cocci warnings Vasyl Gomonovych
2017-11-16 1:37 ` David Miller
2017-11-16 21:35 ` Vasyl Gomonovych
2017-11-16 22:04 ` Vasyl Gomonovych
2017-11-17 15:59 ` Andy Shevchenko
2017-11-18 1:31 ` David Miller
2017-11-20 21:31 ` Vasyl Gomonovych
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).