net/ice: fix wild pointer

Message ID 20191105033806.2878-1-shougangx.wang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: xiaolong ye
Headers
Series net/ice: fix wild pointer |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compilation success Compile Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Shougang Wang Nov. 5, 2019, 3:38 a.m. UTC
  To avoid wild pointer, pointers should be set to NULL after free them.

Fixes: 1a2fc1799f09 ("net/ice: reject duplicated flow for flow director")
Fixes: 84dc7a95a2d3 ("net/ice: enable flow director engine")
Cc: stable@dpdk.org

Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
---
 drivers/net/ice/ice_fdir_filter.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
  

Comments

Xiaolong Ye Nov. 7, 2019, 3:19 a.m. UTC | #1
On 11/05, Wang ShougangX wrote:
>To avoid wild pointer, pointers should be set to NULL after free them.
>
>Fixes: 1a2fc1799f09 ("net/ice: reject duplicated flow for flow director")
>Fixes: 84dc7a95a2d3 ("net/ice: enable flow director engine")
>Cc: stable@dpdk.org
>
>Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
>---
> drivers/net/ice/ice_fdir_filter.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
>index 736ccd54e..d2c754f07 100644
>--- a/drivers/net/ice/ice_fdir_filter.c
>+++ b/drivers/net/ice/ice_fdir_filter.c
>@@ -403,6 +403,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)
> 		rte_free(fdir_info->hash_map);
> 	if (fdir_info->hash_table)
> 		rte_hash_free(fdir_info->hash_table);
>+
>+	fdir_info->hash_map = NULL;
>+	fdir_info->hash_table = NULL;
> }
> 
> /*
>@@ -525,10 +528,13 @@ ice_fdir_prof_free(struct ice_hw *hw)
> 
> 	for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
> 	     ptype < ICE_FLTR_PTYPE_MAX;
>-	     ptype++)
>+	     ptype++) {
> 		rte_free(hw->fdir_prof[ptype]);
>+		hw->fdir_prof[ptype] = NULL;
>+	}
> 
> 	rte_free(hw->fdir_prof);
>+	hw->fdir_prof = NULL;
> }
> 
> /* Remove a profile for some filter type */
>-- 
>2.17.1
>

Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>

Applied to dpdk-next-net-intel. Thanks.
  
Xiaolong Ye Nov. 7, 2019, 3:30 a.m. UTC | #2
On 11/07, Ye Xiaolong wrote:
>On 11/05, Wang ShougangX wrote:
>>To avoid wild pointer, pointers should be set to NULL after free them.
>>
>>Fixes: 1a2fc1799f09 ("net/ice: reject duplicated flow for flow director")
>>Fixes: 84dc7a95a2d3 ("net/ice: enable flow director engine")
>>Cc: stable@dpdk.org
>>
>>Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
>>---
>> drivers/net/ice/ice_fdir_filter.c | 8 +++++++-
>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>
>>diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
>>index 736ccd54e..d2c754f07 100644
>>--- a/drivers/net/ice/ice_fdir_filter.c
>>+++ b/drivers/net/ice/ice_fdir_filter.c
>>@@ -403,6 +403,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)
>> 		rte_free(fdir_info->hash_map);
>> 	if (fdir_info->hash_table)
>> 		rte_hash_free(fdir_info->hash_table);
>>+
>>+	fdir_info->hash_map = NULL;
>>+	fdir_info->hash_table = NULL;
>> }
>> 
>> /*
>>@@ -525,10 +528,13 @@ ice_fdir_prof_free(struct ice_hw *hw)
>> 
>> 	for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
>> 	     ptype < ICE_FLTR_PTYPE_MAX;
>>-	     ptype++)
>>+	     ptype++) {
>> 		rte_free(hw->fdir_prof[ptype]);
>>+		hw->fdir_prof[ptype] = NULL;
>>+	}
>> 
>> 	rte_free(hw->fdir_prof);
>>+	hw->fdir_prof = NULL;
>> }
>> 
>> /* Remove a profile for some filter type */
>>-- 
>>2.17.1
>>
>
>Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
>
>Applied to dpdk-next-net-intel. Thanks.

Please ignore this mail, I'm still waiting for your new patchset.

Thanks,
Xiaolong
  
Shougang Wang Nov. 7, 2019, 5:44 a.m. UTC | #3
> -----Original Message-----
> From: Ye, Xiaolong
> Sent: Thursday, November 7, 2019 11:30 AM
> To: Wang, ShougangX <shougangx.wang@intel.com>
> Cc: dev@dpdk.org; Yang, Qiming <qiming.yang@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>; Cao, Yahui <yahui.cao@intel.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] net/ice: fix wild pointer
> 
> On 11/07, Ye Xiaolong wrote:
> >On 11/05, Wang ShougangX wrote:
> >>To avoid wild pointer, pointers should be set to NULL after free them.
> >>
> >>Fixes: 1a2fc1799f09 ("net/ice: reject duplicated flow for flow director")
> >>Fixes: 84dc7a95a2d3 ("net/ice: enable flow director engine")
> >>Cc: stable@dpdk.org
> >>
> >>Signed-off-by: Wang ShougangX <shougangx.wang@intel.com>
> >>---
> >> drivers/net/ice/ice_fdir_filter.c | 8 +++++++-
> >> 1 file changed, 7 insertions(+), 1 deletion(-)
> >>
> >>diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
> >>index 736ccd54e..d2c754f07 100644
> >>--- a/drivers/net/ice/ice_fdir_filter.c
> >>+++ b/drivers/net/ice/ice_fdir_filter.c
> >>@@ -403,6 +403,9 @@ ice_fdir_release_filter_list(struct ice_pf *pf)
> >> 		rte_free(fdir_info->hash_map);
> >> 	if (fdir_info->hash_table)
> >> 		rte_hash_free(fdir_info->hash_table);
> >>+
> >>+	fdir_info->hash_map = NULL;
> >>+	fdir_info->hash_table = NULL;
> >> }
> >>
> >> /*
> >>@@ -525,10 +528,13 @@ ice_fdir_prof_free(struct ice_hw *hw)
> >>
> >> 	for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
> >> 	     ptype < ICE_FLTR_PTYPE_MAX;
> >>-	     ptype++)
> >>+	     ptype++) {
> >> 		rte_free(hw->fdir_prof[ptype]);
> >>+		hw->fdir_prof[ptype] = NULL;
> >>+	}
> >>
> >> 	rte_free(hw->fdir_prof);
> >>+	hw->fdir_prof = NULL;
> >> }
> >>
> >> /* Remove a profile for some filter type */
> >>--
> >>2.17.1
> >>
> >
> >Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
> >
> >Applied to dpdk-next-net-intel. Thanks.
> 
> Please ignore this mail, I'm still waiting for your new patchset.
> 
OK, I will make a patchset.

> Thanks,
> Xiaolong

Thanks.
Shougang
  

Patch

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 736ccd54e..d2c754f07 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -403,6 +403,9 @@  ice_fdir_release_filter_list(struct ice_pf *pf)
 		rte_free(fdir_info->hash_map);
 	if (fdir_info->hash_table)
 		rte_hash_free(fdir_info->hash_table);
+
+	fdir_info->hash_map = NULL;
+	fdir_info->hash_table = NULL;
 }
 
 /*
@@ -525,10 +528,13 @@  ice_fdir_prof_free(struct ice_hw *hw)
 
 	for (ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP;
 	     ptype < ICE_FLTR_PTYPE_MAX;
-	     ptype++)
+	     ptype++) {
 		rte_free(hw->fdir_prof[ptype]);
+		hw->fdir_prof[ptype] = NULL;
+	}
 
 	rte_free(hw->fdir_prof);
+	hw->fdir_prof = NULL;
 }
 
 /* Remove a profile for some filter type */