Skip to contentSkip to conversation

net/mlx5/hws: fix null dereference in rule skip

PATCH In review Shani Peretz 2 participants 2 messages Jan 21 – Feb 8 Network drivers

lore
Share & tools
lore
#0 lore raw

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")
---
 drivers/net/mlx5/hws/mlx5dr_rule.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/mlx5/hws/mlx5dr_rule.c +4 -0
index 895ac858ec..23327d2b73 100644
@@ -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
#1 lore raw

Hi,

Quoted 11 lines · Shani Peretz

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")

Patch applied to next-net-mlx,

Kindest regards
Raslan Darawsheh