lkml.org 
[lkml]   [2023]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] amd/pds_core: core: No need for Null pointer check before kfree
From
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));
>> }

\
 
 \ /
  Last update: 2023-10-25 13:40    [W:0.847 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site