net/mlx5: fix crash when meter action conf is null
authorTonghao Zhang <xiangxia.m.yue@gmail.com>
Fri, 13 Dec 2019 14:21:34 +0000 (22:21 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 17 Jan 2020 18:46:01 +0000 (19:46 +0100)
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 <xiangxia.m.yue@gmail.com>
Reviewed-by: Suanming Mou <suanmingm@mellanox.com>
drivers/net/mlx5/mlx5_flow_dv.c

index 4c16281..5bd1b1c 100644 (file)
@@ -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,