[PATCH 3/19] PCI: rpaphp: match up alloc and free in same routine

Linas Vepstas linas at austin.ibm.com
Tue Apr 3 10:35:46 EST 2007


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 at austin.ibm.com>
Cc: John Rose <johnrose at austin.ibm.com>

----
 drivers/pci/hotplug/rpaphp_core.c |    5 +++++
 drivers/pci/hotplug/rpaphp_pci.c  |    1 -
 drivers/pci/hotplug/rpaphp_slot.c |    1 -
 3 files changed, 5 insertions(+), 2 deletions(-)

Index: linux-2.6.21-rc4-git4/drivers/pci/hotplug/rpaphp_core.c
===================================================================
--- linux-2.6.21-rc4-git4.orig/drivers/pci/hotplug/rpaphp_core.c	2007-03-28 17:42:01.000000000 -0500
+++ linux-2.6.21-rc4-git4/drivers/pci/hotplug/rpaphp_core.c	2007-03-28 17:42:04.000000000 -0500
@@ -321,10 +321,15 @@ int rpaphp_add_slot(struct device_node *
 				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: linux-2.6.21-rc4-git4/drivers/pci/hotplug/rpaphp_slot.c
===================================================================
--- linux-2.6.21-rc4-git4.orig/drivers/pci/hotplug/rpaphp_slot.c	2007-03-28 17:42:01.000000000 -0500
+++ linux-2.6.21-rc4-git4/drivers/pci/hotplug/rpaphp_slot.c	2007-03-28 17:42:04.000000000 -0500
@@ -184,7 +184,6 @@ int rpaphp_register_slot(struct slot *sl
 sysfs_fail:
 	pci_hp_deregister(php_slot);
 register_fail:
-	rpaphp_release_slot(php_slot);
 	return retval;
 }
 
Index: linux-2.6.21-rc4-git4/drivers/pci/hotplug/rpaphp_pci.c
===================================================================
--- linux-2.6.21-rc4-git4.orig/drivers/pci/hotplug/rpaphp_pci.c	2007-03-28 17:42:01.000000000 -0500
+++ linux-2.6.21-rc4-git4/drivers/pci/hotplug/rpaphp_pci.c	2007-03-28 17:42:04.000000000 -0500
@@ -195,7 +195,6 @@ static int setup_pci_slot(struct slot *s
 	}
 	return 0;
 exit_rc:
-	dealloc_slot_struct(slot);
 	return -EINVAL;
 }
 



More information about the Linuxppc-dev mailing list