From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e4.ny.us.ibm.com (e4.ny.us.ibm.com [32.97.182.144]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "e4.ny.us.ibm.com", Issuer "Equifax" (verified OK)) by ozlabs.org (Postfix) with ESMTP id B1CC2DDE38 for ; Tue, 3 Apr 2007 10:35:51 +1000 (EST) Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e4.ny.us.ibm.com (8.13.8/8.13.8) with ESMTP id l330ZlDR029793 for ; Mon, 2 Apr 2007 20:35:47 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v8.3) with ESMTP id l330ZlPC238016 for ; Mon, 2 Apr 2007 20:35:47 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id l330Zk7F009822 for ; Mon, 2 Apr 2007 20:35:47 -0400 To: Greg KH Subject: [PATCH 3/19] PCI: rpaphp: match up alloc and free in same routine In-Reply-To: <20070403002629.GI4922@austin.ibm.com> Message-Id: <20070403003546.52EE93A65C@topology.austin.ibm.com> Date: Mon, 2 Apr 2007 19:35:46 -0500 (CDT) From: linas@austin.ibm.com (Linas Vepstas) Cc: Andrew Morton , linuxppc-dev@ozlabs.org, linux-pci@atrey.karlin.mff.cuni.cz List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Cc: John Rose ---- 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; }