DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] pipeline: fix deallocate null pointer
@ 2021-04-22  6:38 Min Hu (Connor)
  2021-04-22  8:36 ` Dumitrescu, Cristian
  0 siblings, 1 reply; 3+ messages in thread
From: Min Hu (Connor) @ 2021-04-22  6:38 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, cristian.dumitrescu

From: HongBo Zheng <zhenghongbo3@huawei.com>

Fix deallocate null pointer in instruction_config, while
pointer 'data' or 'instr' may be null.

Fixes: a1711f948dbf ("pipeline: add SWX Rx and extract instructions")
Cc: stable@dpdk.org

Signed-off-by: HongBo Zheng <zhenghongbo3@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 lib/librte_pipeline/rte_swx_pipeline.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pipeline/rte_swx_pipeline.c b/lib/librte_pipeline/rte_swx_pipeline.c
index 4455d91..6084635 100644
--- a/lib/librte_pipeline/rte_swx_pipeline.c
+++ b/lib/librte_pipeline/rte_swx_pipeline.c
@@ -8015,8 +8015,10 @@ instruction_config(struct rte_swx_pipeline *p,
 	return 0;
 
 error:
-	free(data);
-	free(instr);
+	if (data)
+		free(data);
+	if (instr)
+		free(instr);
 	return err;
 }
 
-- 
2.7.4


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

* Re: [dpdk-dev] [PATCH] pipeline: fix deallocate null pointer
  2021-04-22  6:38 [dpdk-dev] [PATCH] pipeline: fix deallocate null pointer Min Hu (Connor)
@ 2021-04-22  8:36 ` Dumitrescu, Cristian
  2021-04-22  9:36   ` Min Hu (Connor)
  0 siblings, 1 reply; 3+ messages in thread
From: Dumitrescu, Cristian @ 2021-04-22  8:36 UTC (permalink / raw)
  To: Min Hu (Connor), dev; +Cc: Yigit, Ferruh



> -----Original Message-----
> From: Min Hu (Connor) <humin29@huawei.com>
> Sent: Thursday, April 22, 2021 7:39 AM
> To: dev@dpdk.org
> Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; Dumitrescu, Cristian
> <cristian.dumitrescu@intel.com>
> Subject: [PATCH] pipeline: fix deallocate null pointer
> 
> From: HongBo Zheng <zhenghongbo3@huawei.com>
> 
> Fix deallocate null pointer in instruction_config, while
> pointer 'data' or 'instr' may be null.
> 
> Fixes: a1711f948dbf ("pipeline: add SWX Rx and extract instructions")
> Cc: stable@dpdk.org
> 
> Signed-off-by: HongBo Zheng <zhenghongbo3@huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> ---
>  lib/librte_pipeline/rte_swx_pipeline.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_pipeline/rte_swx_pipeline.c
> b/lib/librte_pipeline/rte_swx_pipeline.c
> index 4455d91..6084635 100644
> --- a/lib/librte_pipeline/rte_swx_pipeline.c
> +++ b/lib/librte_pipeline/rte_swx_pipeline.c
> @@ -8015,8 +8015,10 @@ instruction_config(struct rte_swx_pipeline *p,
>  	return 0;
> 
>  error:
> -	free(data);
> -	free(instr);
> +	if (data)
> +		free(data);
> +	if (instr)
> +		free(instr);
>  	return err;
>  }
> 
> --
> 2.7.4

Hi,

NACK.

Thanks for the patch, but the tests for data and instr being non-NULL before calling free are not required, because:
1. Both data and instr are initialized to NULL.
2. free(NULL) is supported.

Regards,
Cristian

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

* Re: [dpdk-dev] [PATCH] pipeline: fix deallocate null pointer
  2021-04-22  8:36 ` Dumitrescu, Cristian
@ 2021-04-22  9:36   ` Min Hu (Connor)
  0 siblings, 0 replies; 3+ messages in thread
From: Min Hu (Connor) @ 2021-04-22  9:36 UTC (permalink / raw)
  To: Dumitrescu, Cristian, dev; +Cc: Yigit, Ferruh



在 2021/4/22 16:36, Dumitrescu, Cristian 写道:
> 
> 
>> -----Original Message-----
>> From: Min Hu (Connor) <humin29@huawei.com>
>> Sent: Thursday, April 22, 2021 7:39 AM
>> To: dev@dpdk.org
>> Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; Dumitrescu, Cristian
>> <cristian.dumitrescu@intel.com>
>> Subject: [PATCH] pipeline: fix deallocate null pointer
>>
>> From: HongBo Zheng <zhenghongbo3@huawei.com>
>>
>> Fix deallocate null pointer in instruction_config, while
>> pointer 'data' or 'instr' may be null.
>>
>> Fixes: a1711f948dbf ("pipeline: add SWX Rx and extract instructions")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: HongBo Zheng <zhenghongbo3@huawei.com>
>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>> ---
>>   lib/librte_pipeline/rte_swx_pipeline.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/lib/librte_pipeline/rte_swx_pipeline.c
>> b/lib/librte_pipeline/rte_swx_pipeline.c
>> index 4455d91..6084635 100644
>> --- a/lib/librte_pipeline/rte_swx_pipeline.c
>> +++ b/lib/librte_pipeline/rte_swx_pipeline.c
>> @@ -8015,8 +8015,10 @@ instruction_config(struct rte_swx_pipeline *p,
>>   	return 0;
>>
>>   error:
>> -	free(data);
>> -	free(instr);
>> +	if (data)
>> +		free(data);
>> +	if (instr)
>> +		free(instr);
>>   	return err;
>>   }
>>
>> --
>> 2.7.4
> 
> Hi,
> 
> NACK.
> 
> Thanks for the patch, but the tests for data and instr being non-NULL before calling free are not required, because:
> 1. Both data and instr are initialized to NULL.
> 2. free(NULL) is supported.
> 
Agreed, thanks Cristian, this patch can be abandoned.
> Regards,
> Cristian
> .
> 

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

end of thread, other threads:[~2021-04-22  9:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22  6:38 [dpdk-dev] [PATCH] pipeline: fix deallocate null pointer Min Hu (Connor)
2021-04-22  8:36 ` Dumitrescu, Cristian
2021-04-22  9:36   ` Min Hu (Connor)

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