[v3] net/ice: fix hash flow segmentation fault
diff mbox series

Message ID 20200303053846.10610-1-taox.zhu@intel.com
State Accepted, archived
Delegated to: xiaolong ye
Headers show
Series
  • [v3] net/ice: fix hash flow segmentation fault
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Zhu, TaoX March 3, 2020, 5:38 a.m. UTC
From: Zhu Tao <taox.zhu@intel.com>

Macro rte_errno is not a static value, so it needs to be updated in all
error handling code.

Patch 'dc36bd5dfdeb' mistakenly consider that rte_errno is a constant,
which causes the unrecognized flow rule to be marked as recognition
success. Later, when the code tried to parse the flow rule, a null pointer
caused a segmentation fault.

Fixes: dc36bd5dfdeb ("net/ice: fix flow FDIR/switch memory leak")
Cc: stable@dpdk.org

Signed-off-by: Zhu Tao <taox.zhu@intel.com>
---
v3 Changes:

 Commit message: Use 12 chars length of commit SHA in Fixes line.
 Code: Delete redundant assignment codes.

v2 Changes:

 Commit message: Use 12 chars length of commit SHA in Fixes line.

 drivers/net/ice/ice_hash.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Xiaolong Ye March 3, 2020, 7:16 a.m. UTC | #1
On 03/03, taox.zhu@intel.com wrote:
>From: Zhu Tao <taox.zhu@intel.com>
>
>Macro rte_errno is not a static value, so it needs to be updated in all
>error handling code.
>
>Patch 'dc36bd5dfdeb' mistakenly consider that rte_errno is a constant,
>which causes the unrecognized flow rule to be marked as recognition
>success. Later, when the code tried to parse the flow rule, a null pointer
>caused a segmentation fault.
>
>Fixes: dc36bd5dfdeb ("net/ice: fix flow FDIR/switch memory leak")
>Cc: stable@dpdk.org
>
>Signed-off-by: Zhu Tao <taox.zhu@intel.com>
>---
>v3 Changes:
>
> Commit message: Use 12 chars length of commit SHA in Fixes line.
> Code: Delete redundant assignment codes.
>
>v2 Changes:
>
> Commit message: Use 12 chars length of commit SHA in Fixes line.
>
> drivers/net/ice/ice_hash.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
>index d891538bd..0e9c3c4e5 100644
>--- a/drivers/net/ice/ice_hash.c
>+++ b/drivers/net/ice/ice_hash.c
>@@ -409,7 +409,7 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
> 			void **meta,
> 			struct rte_flow_error *error)
> {
>-	int ret = -rte_errno;
>+	int ret = 0;
> 	struct ice_pattern_match_item *pattern_match_item;
> 	struct rss_meta *rss_meta_ptr;
> 
>@@ -424,8 +424,10 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
> 	/* Check rss supported pattern and find matched pattern. */
> 	pattern_match_item = ice_search_pattern_match_item(pattern,
> 					array, array_len, error);
>-	if (!pattern_match_item)
>+	if (!pattern_match_item) {
>+		ret = -rte_errno;
> 		goto error;
>+	}
> 
> 	ret = ice_hash_check_inset(pattern, error);
> 	if (ret)
>-- 
>2.17.1
>

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

Applied to dpdk-next-net-intel, Thanks.

Patch
diff mbox series

diff --git a/drivers/net/ice/ice_hash.c b/drivers/net/ice/ice_hash.c
index d891538bd..0e9c3c4e5 100644
--- a/drivers/net/ice/ice_hash.c
+++ b/drivers/net/ice/ice_hash.c
@@ -409,7 +409,7 @@  ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
 			void **meta,
 			struct rte_flow_error *error)
 {
-	int ret = -rte_errno;
+	int ret = 0;
 	struct ice_pattern_match_item *pattern_match_item;
 	struct rss_meta *rss_meta_ptr;
 
@@ -424,8 +424,10 @@  ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
 	/* Check rss supported pattern and find matched pattern. */
 	pattern_match_item = ice_search_pattern_match_item(pattern,
 					array, array_len, error);
-	if (!pattern_match_item)
+	if (!pattern_match_item) {
+		ret = -rte_errno;
 		goto error;
+	}
 
 	ret = ice_hash_check_inset(pattern, error);
 	if (ret)