[PATCH V2 net 5/8] net/mlx5: Fix QoS reference leak in vport enable error path

Mark Bloch
2025-08-20T13:33:14Z

From: Carolina Jubran <cjubran@nvidia.com>

Add missing esw_qos_put() call when __esw_qos_alloc_node() fails in
mlx5_esw_qos_vport_enable().

Fixes: be034baba83e ("net/mlx5: Make vport QoS enablement more flexible for future extensions")
Signed-off-by: Carolina Jubran <cjubran@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c
index 452a948a3e6d..41aec07bb6c2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c
@@ -1109,8 +1109,10 @@ static int mlx5_esw_qos_vport_enable(struct mlx5_vport *vport, enum sched_node_t

parent_esw = parent ? parent->esw : esw;
sched_node = __esw_qos_alloc_node(parent_esw, 0, type, parent);
- if (!sched_node)
+ if (!sched_node) {
+ esw_qos_put(esw);
return -ENOMEM;
+ }
if (!parent)
list_add_tail(&sched_node->entry, &esw->qos.domain->nodes);

--
2.34.1