summaryrefslogtreecommitdiffstats
path: root/drivers/staging/dgap
diff options
context:
space:
mode:
authorMark Hounschell <markh@compro.net>2014-03-06 15:25:19 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-03-06 14:16:40 -0800
commit002de0ba878d0892d0bc722210cc924ee4349cea (patch)
treed477462c72b12fca3b546247d0db651f6d290834 /drivers/staging/dgap
parent434b679bdb4d10615701aa152e800123f47274fe (diff)
downloadlinux-stable-002de0ba878d0892d0bc722210cc924ee4349cea.tar.gz
linux-stable-002de0ba878d0892d0bc722210cc924ee4349cea.tar.bz2
linux-stable-002de0ba878d0892d0bc722210cc924ee4349cea.zip
staging: dgap: Simplify and cleanup dgap_init_module function
This patch simplifies and cleans up the dgap_init_module function. It also fixes a possible double free condition as a result pci_unregister_driver possibly being called twice. Signed-off-by: Mark Hounschell <markh@compro.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/dgap')
-rw-r--r--drivers/staging/dgap/dgap.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 3e7cb18f614c..d00283a226a2 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -519,37 +519,25 @@ static int dgap_init_module(void)
dgap_driver_state = DRIVER_NEED_CONFIG_LOAD;
- /*
- * Initialize global stuff
- */
rc = dgap_start();
-
- if (rc < 0)
+ if (rc)
return rc;
- /*
- * Find and configure all the cards
- */
rc = dgap_init_pci();
+ if (rc)
+ goto err_cleanup;
- /*
- * If something went wrong in the scan, bail out of driver.
- */
- if (rc < 0) {
- /* Only unregister the pci driver if it was actually registered. */
- if (dgap_NumBoards)
- pci_unregister_driver(&dgap_driver);
- else
- pr_err("dgap: driver load failed. No boards found.\n");
+ rc = dgap_create_driver_sysfiles(&dgap_driver);
+ if (rc)
+ goto err_cleanup;
- dgap_cleanup_module();
- } else {
- rc = dgap_create_driver_sysfiles(&dgap_driver);
- if (rc)
- dgap_cleanup_module();
- else
- dgap_driver_state = DRIVER_READY;
- }
+ dgap_driver_state = DRIVER_READY;
+
+ return 0;
+
+err_cleanup:
+
+ dgap_cleanup_module();
return rc;
}