From: Chris Wilson <chris@qwirx.com>
This function did check misc_register's return code, but made no effort to
clean up if it failed, leaving a large amount of potential crud lying
around. I moved the registration to the start of the function, so that the
cleanup is trivial, and made sure the device gets unregistered in the
cases where it would not have been registered at all before.
struct vpd_prom *vpdp;
int okboard;
-
#ifdef CONFIG_PCI
#ifndef TWO_ZERO
struct pci_dev *pdev = NULL;
rio_debug=-1;
}
+ if (misc_register(&rio_fw_device) < 0) {
+ printk(KERN_ERR "RIO: Unable to register firmware loader driver.\n");
+ return -EIO;
+ }
+
retval = rio_init_datastructures ();
- if (retval < 0) return retval;
+ if (retval < 0) {
+ misc_deregister(&rio_fw_device);
+ return retval;
+ }
#ifdef CONFIG_PCI
if (pci_present ()) {
if (found) {
rio_dprintk (RIO_DEBUG_INIT, "rio: total of %d boards detected.\n", found);
-
- if (misc_register(&rio_fw_device) < 0) {
- printk(KERN_ERR "RIO: Unable to register firmware loader driver.\n");
- return -EIO;
- }
rio_init_drivers ();
+ } else {
+ /* deregister the misc device we created earlier */
+ misc_deregister(&rio_fw_device);
}
func_exit();