From: Dekel Peled Date: Wed, 4 Nov 2020 14:25:19 +0000 (+0200) Subject: net/mlx5: fix use of local array for global error X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=58df16e08cd55cf7aa3de416117f720a4f166035;p=dpdk.git net/mlx5: fix use of local array for global error Recent patch uses a local string array as input for function rte_flow_error_set(). This stack memory may be later used by other code sections, overwriting the desired error string. This patch implements an error string for the specific case requested, of ICMP item not supported in Verbs flow engine. Fixes: d51475d1bfa5 ("net/mlx5: support item type error message in flow Verbs") Signed-off-by: Dekel Peled Acked-by: Matan Azrad --- diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c index 28fd120f03..04f6b40502 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -1247,7 +1247,6 @@ flow_verbs_validate(struct rte_eth_dev *dev, uint64_t last_item = 0; uint8_t next_protocol = 0xff; uint16_t ether_type = 0; - char errstr[32]; if (items == NULL) return -1; @@ -1398,12 +1397,16 @@ flow_verbs_validate(struct rte_eth_dev *dev, return ret; last_item = MLX5_FLOW_LAYER_MPLS; break; + case RTE_FLOW_ITEM_TYPE_ICMP: + case RTE_FLOW_ITEM_TYPE_ICMP6: + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, "ICMP/ICMP6 " + "item not supported"); default: - snprintf(errstr, sizeof(errstr), "item type %d not supported", - items->type); return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, - NULL, errstr); + NULL, "item not supported"); } item_flags |= last_item; } @@ -1698,7 +1701,6 @@ flow_verbs_translate(struct rte_eth_dev *dev, struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_flow_workspace *wks = mlx5_flow_get_thread_workspace(); struct mlx5_flow_rss_desc *rss_desc; - char errstr[32]; MLX5_ASSERT(wks); rss_desc = &wks->rss_desc[!!wks->flow_nested_idx]; @@ -1846,11 +1848,9 @@ flow_verbs_translate(struct rte_eth_dev *dev, item_flags |= MLX5_FLOW_LAYER_MPLS; break; default: - snprintf(errstr, sizeof(errstr), "item type %d not supported", - items->type); return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, - NULL, errstr); + NULL, "item not supported"); } } dev_flow->handle->layers = item_flags;