IB/mlx5: Fix error handling order in create_kernel_qp
authorEli Cohen <eli@mellanox.com>
Tue, 3 Jan 2017 21:55:20 +0000 (23:55 +0200)
committerLeon Romanovsky <leon@kernel.org>
Sun, 8 Jan 2017 09:21:26 +0000 (11:21 +0200)
Make sure order of cleanup is exactly the opposite of initialization.

Fixes: 9603b61de1ee ('mlx5: Move pci device handling from mlx5_ib to mlx5_core')
Signed-off-by: Eli Cohen <eli@mellanox.com>
Reviewed-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/infiniband/hw/mlx5/qp.c

index 53f4dd32f9565e6205a49d1b4d6aad5095b33e09..42d021cdc6c59bc1c26f25775846f9086ad83d3b 100644 (file)
@@ -994,12 +994,12 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
        return 0;
 
 err_wrid:
-       mlx5_db_free(dev->mdev, &qp->db);
        kfree(qp->sq.wqe_head);
        kfree(qp->sq.w_list);
        kfree(qp->sq.wrid);
        kfree(qp->sq.wr_data);
        kfree(qp->rq.wrid);
+       mlx5_db_free(dev->mdev, &qp->db);
 
 err_free:
        kvfree(*in);
@@ -1014,12 +1014,12 @@ err_uuar:
 
 static void destroy_qp_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp)
 {
-       mlx5_db_free(dev->mdev, &qp->db);
        kfree(qp->sq.wqe_head);
        kfree(qp->sq.w_list);
        kfree(qp->sq.wrid);
        kfree(qp->sq.wr_data);
        kfree(qp->rq.wrid);
+       mlx5_db_free(dev->mdev, &qp->db);
        mlx5_buf_free(dev->mdev, &qp->buf);
        free_uuar(&dev->mdev->priv.uuari, qp->bf->uuarn);
 }