From fa503935c2d6603856dafff0a0852631ab6e9503 Mon Sep 17 00:00:00 2001 From: Cosmin Ratiu Date: Mon, 26 Oct 2026 10:45:03 +0200 Subject: [PATCH] net/mlx5: Only set num_doorbells on a fully initialized SF The validation for the num_doorbells devlink param rejects values greater than num_channels. For lightweight SFs, this ends up accessing a NULL priv->eq_table, leading to a crash. Fix that by rejecting setting num_doorbells on uninitialized SFs. Fixes: 11bbcfb7668c ("net/mlx5e: Use the 'num_doorbells' devlink param") Signed-off-by: Cosmin Ratiu Reviewed-by: Dragos Tatulea Signed-off-by: Tariq Toukan Reviewed-by: Daniel Machon Link: https://patch.msgid.link/20261026084503.4122732-1-tariqt@nvidia.com Signed-off-by: Paolo Abeni --- drivers/net/ethernet/mellanox/mlx5/core/devlink.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c index b9026cc64383..30a97e48dda7 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c @@ -542,6 +542,12 @@ static int mlx5_devlink_num_doorbells_validate(struct devlink *devlink, u32 id, u32 val32 = val->vu32; u32 max_num_channels; + if (mlx5_dev_is_lightweight(mdev)) { + NL_SET_ERR_MSG_MOD(extack, + "Setting num_doorbells requires full device initialization; reload the device first"); + return -EOPNOTSUPP; + } + max_num_channels = mlx5e_get_max_num_channels(mdev); if (val32 > max_num_channels) { NL_SET_ERR_MSG_FMT_MOD(extack,