]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
IB/qib: Fix debugfs ordering issue with multiple HCAs
authorMike Marciniszyn <mike.marciniszyn@intel.com>
Fri, 7 Mar 2014 13:32:31 +0000 (08:32 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 6 May 2014 14:59:28 +0000 (07:59 -0700)
commit f8b6c47a44c063062317646683a73371c24c69ee upstream.

The debugfs init code was incorrectly called before the idr mechanism
is used to get the unit number, so the dd->unit hasn't been
initialized.  This caused the unit relative directory creation to fail
after the first.

This patch moves the init for the debugfs stuff until after all of the
failures and after the unit number has been determined.

A bug in unwind code in qib_alloc_devdata() is also fixed.

Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/hw/qib/qib_init.c

index 24e802f4ea2f04b4554678eee76341043801cd35..76c3e177164dcdd4f654c33bce9008bea8fe843a 100644 (file)
@@ -1097,14 +1097,10 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra)
        int ret;
 
        dd = (struct qib_devdata *) ib_alloc_device(sizeof(*dd) + extra);
-       if (!dd) {
-               dd = ERR_PTR(-ENOMEM);
-               goto bail;
-       }
+       if (!dd)
+               return ERR_PTR(-ENOMEM);
 
-#ifdef CONFIG_DEBUG_FS
-       qib_dbg_ibdev_init(&dd->verbs_dev);
-#endif
+       INIT_LIST_HEAD(&dd->list);
 
        idr_preload(GFP_KERNEL);
        spin_lock_irqsave(&qib_devs_lock, flags);
@@ -1121,11 +1117,6 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra)
        if (ret < 0) {
                qib_early_err(&pdev->dev,
                              "Could not allocate unit ID: error %d\n", -ret);
-#ifdef CONFIG_DEBUG_FS
-               qib_dbg_ibdev_exit(&dd->verbs_dev);
-#endif
-               ib_dealloc_device(&dd->verbs_dev.ibdev);
-               dd = ERR_PTR(ret);
                goto bail;
        }
 
@@ -1139,9 +1130,15 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra)
                        qib_early_err(&pdev->dev,
                                "Could not alloc cpulist info, cpu affinity might be wrong\n");
        }
-
-bail:
+#ifdef CONFIG_DEBUG_FS
+       qib_dbg_ibdev_init(&dd->verbs_dev);
+#endif
        return dd;
+bail:
+       if (!list_empty(&dd->list))
+               list_del_init(&dd->list);
+       ib_dealloc_device(&dd->verbs_dev.ibdev);
+       return ERR_PTR(ret);;
 }
 
 /*