When pattern/action template creation fails the testpmd expects error
details.
The driver did not set the error structure and testpmd failed with a
segmentation fault.

Signed-off-by: Rongwei Liu <rongw...@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viachesl...@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 907aab8bf3..38b9d55f3a 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -4570,8 +4570,12 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev,
                                                       &at->flex_item)) ||
                             (info->src.field == RTE_FLOW_FIELD_FLEX_ITEM &&
                              flow_hw_flex_item_acquire(dev, 
info->src.flex_handle,
-                                                       &at->flex_item)))
+                                                       &at->flex_item))) {
+                               rte_flow_error_set(error, rte_errno,
+                                                  
RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+                                                  "Failed to acquire flex 
item");
                                goto error;
+                       }
                }
        }
        at->tmpl = flow_hw_dr_actions_template_create(at);
@@ -4587,6 +4591,9 @@ flow_hw_actions_template_create(struct rte_eth_dev *dev,
                        mlx5dr_action_template_destroy(at->tmpl);
                mlx5_free(at);
        }
+       rte_flow_error_set(error, rte_errno,
+                          RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+                          "Failed to create action template");
        return NULL;
 }
 
@@ -4936,6 +4943,9 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
                    (mlx5_alloc_srh_flex_parser(dev))) {
                        claim_zero(mlx5dr_match_template_destroy(it->mt));
                        mlx5_free(it);
+                       rte_flow_error_set(error, rte_errno,
+                                          RTE_FLOW_ERROR_TYPE_UNSPECIFIED, 
NULL,
+                                          "cannot create IPv6 routing 
extension support");
                        return NULL;
                }
        }
@@ -4948,6 +4958,9 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
                        if (flow_hw_flex_item_acquire(dev, handle, 
&it->flex_item)) {
                                
claim_zero(mlx5dr_match_template_destroy(it->mt));
                                mlx5_free(it);
+                               rte_flow_error_set(error, rte_errno,
+                                                  
RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+                                                  "Failed to accquire flex 
item");
                                return NULL;
                        }
                }
-- 
2.27.0

Reply via email to