ntb: idt: Fix error handling in idt_pci_driver_init()
[linux-2.6-microblaze.git] / drivers / ntb / hw / idt / ntb_hw_idt.c
index 0ed6f80..51799fc 100644 (file)
@@ -2891,6 +2891,7 @@ static struct pci_driver idt_pci_driver = {
 
 static int __init idt_pci_driver_init(void)
 {
+       int ret;
        pr_info("%s %s\n", NTB_DESC, NTB_VER);
 
        /* Create the top DebugFS directory if the FS is initialized */
@@ -2898,7 +2899,11 @@ static int __init idt_pci_driver_init(void)
                dbgfs_topdir = debugfs_create_dir(KBUILD_MODNAME, NULL);
 
        /* Register the NTB hardware driver to handle the PCI device */
-       return pci_register_driver(&idt_pci_driver);
+       ret = pci_register_driver(&idt_pci_driver);
+       if (ret)
+               debugfs_remove_recursive(dbgfs_topdir);
+
+       return ret;
 }
 module_init(idt_pci_driver_init);