Skip to contentSkip to conversation

net/mlx5: fix bug trunk is null

PATCH In review Haifei Luo 2 participants 2 messages May 15, 2024 – May 20, 2024 Network drivers

lore
Share & tools
lore

Haifei Luo

author
#0 lore raw

PATCH 1/1 net/mlx5: fix bug trunk is null

When _mlx5_ipool_get_cache is called, idx may be invalid and the "trunk" is NULL in this case. Assert is not correct and add checks that if trunk is NULL or not. Return NULL If trunk is NULL.

Fixes 42f463395f ("net/mlx5: support indexed pool non-lcore operations")
---
 drivers/net/mlx5/mlx5_utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_utils.c +2 -1
index e28db2ec43..93c10f20a7 100644
@@ -379,7 +379,8 @@ _mlx5_ipool_get_cache(struct mlx5_indexed_pool *pool, int cidx, uint32_t idx)
 	idx -= 1;
 	trunk_idx = mlx5_trunk_idx_get(pool, idx);
 	trunk = lc->trunks[trunk_idx];
-	MLX5_ASSERT(trunk);
+	if (!trunk)
+		return NULL;
 	entry_idx = idx - mlx5_trunk_idx_offset_get(pool, trunk_idx);
 	return &trunk->data[entry_idx * pool->cfg.size];
 }
Signature · 1 line
2.39.3
Acked-by Suanming Mou on v1 1/1
#1 lore raw

Hi,

From: Haifei Luo <[email protected]>
Sent: Wednesday, May 15, 2024 12:36 PM
To: Matan Azrad; Ori Kam; Slava Ovsiienko; [email protected]; Dariusz Sosnowski; Suanming Mou
Cc: [email protected]; NBU-Contact-Thomas Monjalon (EXTERNAL); Raslan Darawsheh; [email protected]
Subject: [PATCH] net/mlx5: fix bug trunk is null

When _mlx5_ipool_get_cache is called, idx may be invalid and the "trunk" is NULL in this case. Assert is not correct and add checks that if trunk is NULL or not. Return NULL If trunk is NULL.

Fixes 42f463395f ("net/mlx5: support indexed pool non-lcore operations")

Patch applied to next-net-mlx,

Kindest regards
Raslan Darawsheh