RDMA/qedr: clean up work queue on failure in qedr_alloc_resources()
[sfrench/cifs-2.6.git] / drivers / infiniband / hw / qedr / main.c
index 5152f10d2e6de9953522588feae005180b7dde42..ba0c3e4c07d85cda8c517afbb9304b262da26989 100644 (file)
@@ -344,6 +344,10 @@ static int qedr_alloc_resources(struct qedr_dev *dev)
        if (IS_IWARP(dev)) {
                xa_init(&dev->qps);
                dev->iwarp_wq = create_singlethread_workqueue("qedr_iwarpq");
+               if (!dev->iwarp_wq) {
+                       rc = -ENOMEM;
+                       goto err1;
+               }
        }
 
        /* Allocate Status blocks for CNQ */
@@ -351,7 +355,7 @@ static int qedr_alloc_resources(struct qedr_dev *dev)
                                GFP_KERNEL);
        if (!dev->sb_array) {
                rc = -ENOMEM;
-               goto err1;
+               goto err_destroy_wq;
        }
 
        dev->cnq_array = kcalloc(dev->num_cnq,
@@ -402,6 +406,9 @@ err3:
        kfree(dev->cnq_array);
 err2:
        kfree(dev->sb_array);
+err_destroy_wq:
+       if (IS_IWARP(dev))
+               destroy_workqueue(dev->iwarp_wq);
 err1:
        kfree(dev->sgid_tbl);
        return rc;