From 4f19f4140e058c92822f228dcdc55c44bd88b613 Mon Sep 17 00:00:00 2001 From: Tonghao Zhang Date: Fri, 13 Dec 2019 22:21:34 +0800 Subject: [PATCH] net/mlx5: fix crash when meter action conf is null When offloading the meter, should check the action conf and make sure it is valid. Fixes: f46bf7488705 ("net/mlx5: support meter flow action") Cc: stable@dpdk.org Signed-off-by: Tonghao Zhang Reviewed-by: Suanming Mou --- drivers/net/mlx5/mlx5_flow_dv.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 4c162816e4..5bd1b1cdb7 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -3402,7 +3402,12 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev, { struct mlx5_priv *priv = dev->data->dev_private; const struct rte_flow_action_meter *am = action->conf; - struct mlx5_flow_meter *fm = mlx5_flow_meter_find(priv, am->mtr_id); + struct mlx5_flow_meter *fm; + + if (!am) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "meter action conf is NULL"); if (action_flags & MLX5_FLOW_ACTION_METER) return rte_flow_error_set(error, ENOTSUP, @@ -3417,6 +3422,7 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "meter action not supported"); + fm = mlx5_flow_meter_find(priv, am->mtr_id); if (!fm) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL, -- 2.20.1