net/mlx5/hws: fix null dereference in rule skip
PATCH 1/1 net/mlx5/hws: fix null dereference in rule skip
When using template API with a represented_port pattern item that has no spec, mlx5dr_rule_skip() dereferences a NULL pointer when accessing v->port_id.
Now validating the spec before accessing port_id.
Fixes 405242c52dd5 ("net/mlx5/hws: add rule object")
Signed-off-by Shani Peretz <[email protected]>
Acked-by Bing Zhao <[email protected]>
--- drivers/net/mlx5/hws/mlx5dr_rule.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/mlx5/hws/mlx5dr_rule.c +4 -0
@@ -38,6 +38,10 @@ static void mlx5dr_rule_skip(struct mlx5dr_matcher *matcher,if (mt->item_flags &MLX5_FLOW_ITEM_REPRESENTED_PORT ) { v = items[mt->vport_item_id].spec; +if (unlikely (!v)) { +DR_LOG (NOTICE ,"Fail to get vport item, ignoring" ); +return ; + } vport =flow_hw_conv_port_id (matcher->tbl->ctx, v->port_id);if (unlikely (!vport)) {DR_LOG (ERR ,"Fail to map port ID %d, ignoring" , v->port_id);
Signature · 1 line
2.43.0
Hi,
Quoted 11 lines · Shani Peretz
When using template API with a
represented_portpattern item that has no spec,mlx5dr_rule_skip()dereferences a NULL pointer when accessingv->port_id.Now validating the spec before accessing
port_id.Fixes 405242c52dd5 ("net/mlx5/hws: add rule object")Signed-off-by Shani Peretz <[email protected]>Acked-by Bing Zhao <[email protected]>
Patch applied to next-net-mlx,
Kindest regards
Raslan Darawsheh