iwlwifi: fix module init error paths
authorJohannes Berg <johannes.berg@intel.com>
Fri, 10 May 2019 10:35:17 +0000 (12:35 +0200)
committerLuca Coelho <luciano.coelho@intel.com>
Sat, 29 Jun 2019 07:09:39 +0000 (10:09 +0300)
When the module fails to initialize for some reason, it
doesn't clean up properly. Fix that.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/iwl-drv.c

index 4d6249b7bb0d4ba6df20c000697fa3faa67de6d8..063313f4a99209acedb27762225379bbb3ccfe98 100644 (file)
@@ -1745,7 +1745,7 @@ IWL_EXPORT_SYMBOL(iwl_opmode_deregister);
 
 static int __init iwl_drv_init(void)
 {
-       int i;
+       int i, err;
 
        mutex_init(&iwlwifi_opmode_table_mtx);
 
@@ -1760,7 +1760,17 @@ static int __init iwl_drv_init(void)
        iwl_dbgfs_root = debugfs_create_dir(DRV_NAME, NULL);
 #endif
 
-       return iwl_pci_register_driver();
+       err = iwl_pci_register_driver();
+       if (err)
+               goto cleanup_debugfs;
+
+       return 0;
+
+cleanup_debugfs:
+#ifdef CONFIG_IWLWIFI_DEBUGFS
+       debugfs_remove_recursive(iwl_dbgfs_root);
+#endif
+       return err;
 }
 module_init(iwl_drv_init);