Skip to content

Commit e1a0bdb

Browse files
PatrisiousHaddadrleon
authored andcommitted
RDMA/mlx5: Fix bind QP error cleanup flow
When there is a failure during bind QP, the cleanup flow destroys the counter regardless if it is the one that created it or not, which is problematic since if it isn't the one that created it, that counter could still be in use. Fix that by destroying the counter only if it was created during this call. Fixes: 45842fc ("IB/mlx5: Support statistic q counter configuration") Signed-off-by: Patrisious Haddad <phaddad@nvidia.com> Reviewed-by: Mark Zhang <markzhang@nvidia.com> Link: https://patch.msgid.link/25dfefddb0ebefa668c32e06a94d84e3216257cf.1740033937.git.leon@kernel.org Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev> Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent c534ffd commit e1a0bdb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/infiniband/hw/mlx5/counters.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ static int mlx5_ib_counter_bind_qp(struct rdma_counter *counter,
546546
struct ib_qp *qp)
547547
{
548548
struct mlx5_ib_dev *dev = to_mdev(qp->device);
549+
bool new = false;
549550
int err;
550551

551552
if (!counter->id) {
@@ -560,6 +561,7 @@ static int mlx5_ib_counter_bind_qp(struct rdma_counter *counter,
560561
return err;
561562
counter->id =
562563
MLX5_GET(alloc_q_counter_out, out, counter_set_id);
564+
new = true;
563565
}
564566

565567
err = mlx5_ib_qp_set_counter(qp, counter);
@@ -569,8 +571,10 @@ static int mlx5_ib_counter_bind_qp(struct rdma_counter *counter,
569571
return 0;
570572

571573
fail_set_counter:
572-
mlx5_ib_counter_dealloc(counter);
573-
counter->id = 0;
574+
if (new) {
575+
mlx5_ib_counter_dealloc(counter);
576+
counter->id = 0;
577+
}
574578

575579
return err;
576580
}

0 commit comments

Comments
 (0)