netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] amd/pds_core: core: No need for Null pointer check before kfree
@ 2023-10-24 18:20 Bragatheswaran Manickavel
  2023-10-24 20:58 ` Nelson, Shannon
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Bragatheswaran Manickavel @ 2023-10-24 18:20 UTC (permalink / raw)
  To: shannon.nelson, brett.creeley, davem, edumazet, kuba, pabeni
  Cc: Bragatheswaran Manickavel, netdev, linux-kernel

kfree()/vfree() internally perform NULL check on the
pointer handed to it and take no action if it indeed is
NULL. Hence there is no need for a pre-check of the memory
pointer before handing it to kfree()/vfree().

Issue reported by ifnullfree.cocci Coccinelle semantic
patch script.

Signed-off-by: Bragatheswaran Manickavel <bragathemanick0908@gmail.com>
---
 drivers/net/ethernet/amd/pds_core/core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c
index 2a8643e167e1..0d2091e9eb28 100644
--- a/drivers/net/ethernet/amd/pds_core/core.c
+++ b/drivers/net/ethernet/amd/pds_core/core.c
@@ -152,11 +152,8 @@ void pdsc_qcq_free(struct pdsc *pdsc, struct pdsc_qcq *qcq)
 		dma_free_coherent(dev, qcq->cq_size,
 				  qcq->cq_base, qcq->cq_base_pa);
 
-	if (qcq->cq.info)
-		vfree(qcq->cq.info);
-
-	if (qcq->q.info)
-		vfree(qcq->q.info);
+	vfree(qcq->cq.info);
+	vfree(qcq->q.info);
 
 	memset(qcq, 0, sizeof(*qcq));
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] amd/pds_core: core: No need for Null pointer check before kfree
  2023-10-24 18:20 [PATCH] amd/pds_core: core: No need for Null pointer check before kfree Bragatheswaran Manickavel
@ 2023-10-24 20:58 ` Nelson, Shannon
  2023-10-25  9:22 ` Wojciech Drewek
  2023-10-25  9:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: Nelson, Shannon @ 2023-10-24 20:58 UTC (permalink / raw)
  To: Bragatheswaran Manickavel, brett.creeley, davem, edumazet, kuba,
	pabeni
  Cc: netdev, linux-kernel

On 10/24/2023 11:20 AM, Bragatheswaran Manickavel wrote:
> 
> kfree()/vfree() internally perform NULL check on the
> pointer handed to it and take no action if it indeed is
> NULL. Hence there is no need for a pre-check of the memory
> pointer before handing it to kfree()/vfree().
> 
> Issue reported by ifnullfree.cocci Coccinelle semantic
> patch script.
> 
> Signed-off-by: Bragatheswaran Manickavel <bragathemanick0908@gmail.com>

Thanks -sln

Reviewed-by: Shannon Nelson <shannon.nelson@amd.com>


> ---
>   drivers/net/ethernet/amd/pds_core/core.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c
> index 2a8643e167e1..0d2091e9eb28 100644
> --- a/drivers/net/ethernet/amd/pds_core/core.c
> +++ b/drivers/net/ethernet/amd/pds_core/core.c
> @@ -152,11 +152,8 @@ void pdsc_qcq_free(struct pdsc *pdsc, struct pdsc_qcq *qcq)
>                  dma_free_coherent(dev, qcq->cq_size,
>                                    qcq->cq_base, qcq->cq_base_pa);
> 
> -       if (qcq->cq.info)
> -               vfree(qcq->cq.info);
> -
> -       if (qcq->q.info)
> -               vfree(qcq->q.info);
> +       vfree(qcq->cq.info);
> +       vfree(qcq->q.info);
> 
>          memset(qcq, 0, sizeof(*qcq));
>   }
> --
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] amd/pds_core: core: No need for Null pointer check before kfree
  2023-10-24 18:20 [PATCH] amd/pds_core: core: No need for Null pointer check before kfree Bragatheswaran Manickavel
  2023-10-24 20:58 ` Nelson, Shannon
@ 2023-10-25  9:22 ` Wojciech Drewek
  2023-10-25 11:39   ` Bragatheswaran Manickavel
  2023-10-25  9:40 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: Wojciech Drewek @ 2023-10-25  9:22 UTC (permalink / raw)
  To: Bragatheswaran Manickavel, shannon.nelson, brett.creeley, davem,
	edumazet, kuba, pabeni
  Cc: netdev, linux-kernel



On 24.10.2023 20:20, Bragatheswaran Manickavel wrote:
> kfree()/vfree() internally perform NULL check on the
> pointer handed to it and take no action if it indeed is
> NULL. Hence there is no need for a pre-check of the memory
> pointer before handing it to kfree()/vfree().
> 
> Issue reported by ifnullfree.cocci Coccinelle semantic
> patch script.
> 
> Signed-off-by: Bragatheswaran Manickavel <bragathemanick0908@gmail.com>
> ---

Thanks for the patch!
One nit, you're missing a target tag. It should be [PATCH net-next] since this not a fix IMO.
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>

>  drivers/net/ethernet/amd/pds_core/core.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c
> index 2a8643e167e1..0d2091e9eb28 100644
> --- a/drivers/net/ethernet/amd/pds_core/core.c
> +++ b/drivers/net/ethernet/amd/pds_core/core.c
> @@ -152,11 +152,8 @@ void pdsc_qcq_free(struct pdsc *pdsc, struct pdsc_qcq *qcq)
>  		dma_free_coherent(dev, qcq->cq_size,
>  				  qcq->cq_base, qcq->cq_base_pa);
>  
> -	if (qcq->cq.info)
> -		vfree(qcq->cq.info);
> -
> -	if (qcq->q.info)
> -		vfree(qcq->q.info);
> +	vfree(qcq->cq.info);
> +	vfree(qcq->q.info);
>  
>  	memset(qcq, 0, sizeof(*qcq));
>  }

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] amd/pds_core: core: No need for Null pointer check before kfree
  2023-10-24 18:20 [PATCH] amd/pds_core: core: No need for Null pointer check before kfree Bragatheswaran Manickavel
  2023-10-24 20:58 ` Nelson, Shannon
  2023-10-25  9:22 ` Wojciech Drewek
@ 2023-10-25  9:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-10-25  9:40 UTC (permalink / raw)
  To: Bragatheswaran Manickavel
  Cc: shannon.nelson, brett.creeley, davem, edumazet, kuba, pabeni,
	netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Tue, 24 Oct 2023 23:50:51 +0530 you wrote:
> kfree()/vfree() internally perform NULL check on the
> pointer handed to it and take no action if it indeed is
> NULL. Hence there is no need for a pre-check of the memory
> pointer before handing it to kfree()/vfree().
> 
> Issue reported by ifnullfree.cocci Coccinelle semantic
> patch script.
> 
> [...]

Here is the summary with links:
  - amd/pds_core: core: No need for Null pointer check before kfree
    https://git.kernel.org/netdev/net-next/c/d0110443cf4a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] amd/pds_core: core: No need for Null pointer check before kfree
  2023-10-25  9:22 ` Wojciech Drewek
@ 2023-10-25 11:39   ` Bragatheswaran Manickavel
  0 siblings, 0 replies; 5+ messages in thread
From: Bragatheswaran Manickavel @ 2023-10-25 11:39 UTC (permalink / raw)
  To: Wojciech Drewek, shannon.nelson, brett.creeley, davem, edumazet,
	kuba, pabeni
  Cc: netdev, linux-kernel

Thanks Shannon!

On 25/10/23 14:52, Wojciech Drewek wrote:
>
> On 24.10.2023 20:20, Bragatheswaran Manickavel wrote:
>> kfree()/vfree() internally perform NULL check on the
>> pointer handed to it and take no action if it indeed is
>> NULL. Hence there is no need for a pre-check of the memory
>> pointer before handing it to kfree()/vfree().
>>
>> Issue reported by ifnullfree.cocci Coccinelle semantic
>> patch script.
>>
>> Signed-off-by: Bragatheswaran Manickavel <bragathemanick0908@gmail.com>
>> ---
> Thanks for the patch!
> One nit, you're missing a target tag. It should be [PATCH net-next] since this not a fix IMO.
> Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
Hi Wojciech,
Will take care of this next time. Thanks!
>>   drivers/net/ethernet/amd/pds_core/core.c | 7 ++-----
>>   1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c
>> index 2a8643e167e1..0d2091e9eb28 100644
>> --- a/drivers/net/ethernet/amd/pds_core/core.c
>> +++ b/drivers/net/ethernet/amd/pds_core/core.c
>> @@ -152,11 +152,8 @@ void pdsc_qcq_free(struct pdsc *pdsc, struct pdsc_qcq *qcq)
>>   		dma_free_coherent(dev, qcq->cq_size,
>>   				  qcq->cq_base, qcq->cq_base_pa);
>>   
>> -	if (qcq->cq.info)
>> -		vfree(qcq->cq.info);
>> -
>> -	if (qcq->q.info)
>> -		vfree(qcq->q.info);
>> +	vfree(qcq->cq.info);
>> +	vfree(qcq->q.info);
>>   
>>   	memset(qcq, 0, sizeof(*qcq));
>>   }

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-10-25 11:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-24 18:20 [PATCH] amd/pds_core: core: No need for Null pointer check before kfree Bragatheswaran Manickavel
2023-10-24 20:58 ` Nelson, Shannon
2023-10-25  9:22 ` Wojciech Drewek
2023-10-25 11:39   ` Bragatheswaran Manickavel
2023-10-25  9:40 ` patchwork-bot+netdevbpf

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).