]> err.no Git - linux-2.6/commitdiff
PCI: rpaphp: match up alloc and free in same routine
authorLinas Vepstas <linas@austin.ibm.com>
Fri, 13 Apr 2007 22:34:09 +0000 (15:34 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 3 May 2007 02:02:38 +0000 (19:02 -0700)
The routine that called an alloc should be the same routine that
calles the mathcing free, if anything in the middle failed.

Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Cc: John Rose <johnrose@austin.ibm.com>
Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/pci/hotplug/rpaphp_core.c
drivers/pci/hotplug/rpaphp_pci.c
drivers/pci/hotplug/rpaphp_slot.c

index 3afd154bf543d3afc04c3646f843b532db4b8655..ca95e1515d6f2844185a32774b1d4da16d371639 100644 (file)
@@ -321,10 +321,15 @@ int rpaphp_add_slot(struct device_node *dn)
                                indexes[i + 1], name, type);
 
                retval = rpaphp_register_pci_slot(slot);
+               if (retval)
+                       dealloc_slot_struct(slot);
+
                name += strlen(name) + 1;
                type += strlen(type) + 1;
        }
        dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval);
+
+       /* XXX FIXME: reports a failure only if last entry in loop failed */
        return retval;
 }
 
index 6f6cbede5135cde8cd7f9a8a2b68c6a77b7c8ea9..a669ba3f29c9fc9367257463ab11637e59df899b 100644 (file)
@@ -195,7 +195,6 @@ static int setup_pci_slot(struct slot *slot)
        }
        return 0;
 exit_rc:
-       dealloc_slot_struct(slot);
        return -EINVAL;
 }
 
index 907f1301f84afbc456e39d014d1dae2cde3cd6d0..dd1e275a82ce5ade1d8157e2862d834e45e1443d 100644 (file)
@@ -184,7 +184,6 @@ int rpaphp_register_slot(struct slot *slot)
 sysfs_fail:
        pci_hp_deregister(php_slot);
 register_fail:
-       rpaphp_release_slot(php_slot);
        return retval;
 }