[PATCH net] net/mlx4_core: Fix potential special QP allocation leak on setup failure

From: Guangshuo Li

Date: Fri Dec 04 2026 - 08:05:34 EST


Multi-function masters also allocate the special QP capability array.
If later setup fails, the load error path only frees it for slaves.

Release the array for either role, as the normal unload path does.

This issue was found by our static analysis tool under development.

Fixes: c73c8b1e47ca ("net/mlx4_core: Dynamically allocate structs at mlx4_slave_cap")
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
drivers/net/ethernet/mellanox/mlx4/main.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index c851daa5da9f..49f82c6ca1c1 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -3742,8 +3742,7 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data,
mlx4_multi_func_cleanup(dev);
}

- if (mlx4_is_slave(dev))
- mlx4_slave_destroy_special_qp_cap(dev);
+ mlx4_slave_destroy_special_qp_cap(dev);

err_close:
mlx4_close_hca(dev);

base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907