Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net/mlx5: Fix divide by zero when a function has no completion EQs
@ 2026-12-02 13:04 Tariq Toukan
  2026-12-02 13:08 ` netdev-bot+sinfo
  0 siblings, 1 reply; 2+ messages in thread
From: Tariq Toukan @ 2026-12-02 13:04 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	netdev, Paolo Abeni, Willem de Bruijn
  Cc: Dragos Tatulea, Gal Pressman, Jiri Pirko, Leon Romanovsky,
	linux-rdma, Mark Bloch, Parav Pandit, Saeed Mahameed,
	Shahar Shitrit, Shay Drory, Tariq Toukan, Yishai Hadas

From: Yishai Hadas <yishaih@nvidia.com>

Since max_io_eqs was added, an administrator can set it to 0 for a VF,
or for the host PF from the ECPF. The function then gets only the
control EQs, and with ODP enabled get_num_eqs() returns 0 completion
EQs.

The aRFS version of alloc_rmap() passes the zero value to
alloc_irq_cpu_rmap() which results in a divide by zero.

Handle the zero case by returning an error for non SFs: aRFS
can't function without it.

Fixes: 93197c7c509d ("mlx5/core: Support max_io_eqs for a function")
Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Shahar Shitrit <shshitrit@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/eq.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
index d11ec263d53c..0795ee24ad7f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
@@ -930,6 +930,9 @@ static int alloc_rmap(struct mlx5_core_dev *mdev)
 	if (mlx5_core_is_sf(mdev))
 		return 0;
 
+	if (!eq_table->max_comp_eqs)
+		return -EINVAL;
+
 	eq_table->rmap = alloc_irq_cpu_rmap(eq_table->max_comp_eqs);
 	if (!eq_table->rmap)
 		return -ENOMEM;

base-commit: b6c8f45ed340f00bf2004d407cf7316fe3e24c48
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-02 13:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 13:04 [PATCH net] net/mlx5: Fix divide by zero when a function has no completion EQs Tariq Toukan
2026-12-02 13:08 ` netdev-bot+sinfo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox