From f21a98196a914912a0686b91b134672548badc4f Mon Sep 17 00:00:00 2001 From: Bing Zhao Date: Fri, 17 Apr 2020 15:30:44 +0800 Subject: [PATCH 1/1] net/mlx5: fix empty flow error structure The output flow error parameter is used to indicate the detailed reason of the failure when calling a rte_flow_* interface. Even though sometimes the application will not check it or use it, the PMD must fill it in the failure branch before returning. Or else, some dirty value in the stack, heap will be accessed as a pointer and then cause a crash. In this case, when a port is stopped, it is not allowed to insert a flow from application. The detailed error information should be filled. If the application needs to check the detailed error reason, it will get the information but not result in any crash. Fixes: 40b9e7f65fe1 ("net/mlx5: check device status before creating flow") Signed-off-by: Bing Zhao Acked-by: Ori Kam --- drivers/net/mlx5/mlx5_flow.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 3d256a2f60..e9ae2f782c 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -4524,9 +4524,12 @@ mlx5_flow_create(struct rte_eth_dev *dev, * are not affected. */ if (unlikely(!dev->data->dev_started)) { - rte_errno = ENODEV; DRV_LOG(DEBUG, "port %u is not started when " "inserting a flow", dev->data->port_id); + rte_flow_error_set(error, ENODEV, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "port not started"); return NULL; } return (void *)(uintptr_t)flow_list_create(dev, &priv->flows, -- 2.20.1