Commit 7a47e077 authored by Dan Carpenter's avatar Dan Carpenter Committed by Jason Gunthorpe
Browse files

RDMA/qedr: clean up work queue on failure in qedr_alloc_resources()



Add a check for if create_singlethread_workqueue() fails and also destroy
the work queue on failure paths.

Fixes: e411e058 ("RDMA/qedr: Add iWARP connection management functions")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/Y1gBkDucQhhWj5YM@kili


Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 07c0d131
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -344,6 +344,10 @@ static int qedr_alloc_resources(struct qedr_dev *dev)
	if (IS_IWARP(dev)) {
	if (IS_IWARP(dev)) {
		xa_init(&dev->qps);
		xa_init(&dev->qps);
		dev->iwarp_wq = create_singlethread_workqueue("qedr_iwarpq");
		dev->iwarp_wq = create_singlethread_workqueue("qedr_iwarpq");
		if (!dev->iwarp_wq) {
			rc = -ENOMEM;
			goto err1;
		}
	}
	}


	/* Allocate Status blocks for CNQ */
	/* Allocate Status blocks for CNQ */
@@ -351,7 +355,7 @@ static int qedr_alloc_resources(struct qedr_dev *dev)
				GFP_KERNEL);
				GFP_KERNEL);
	if (!dev->sb_array) {
	if (!dev->sb_array) {
		rc = -ENOMEM;
		rc = -ENOMEM;
		goto err1;
		goto err_destroy_wq;
	}
	}


	dev->cnq_array = kcalloc(dev->num_cnq,
	dev->cnq_array = kcalloc(dev->num_cnq,
@@ -402,6 +406,9 @@ static int qedr_alloc_resources(struct qedr_dev *dev)
	kfree(dev->cnq_array);
	kfree(dev->cnq_array);
err2:
err2:
	kfree(dev->sb_array);
	kfree(dev->sb_array);
err_destroy_wq:
	if (IS_IWARP(dev))
		destroy_workqueue(dev->iwarp_wq);
err1:
err1:
	kfree(dev->sgid_tbl);
	kfree(dev->sgid_tbl);
	return rc;
	return rc;