aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesper Juhl <jesper.juhl@gmail.com>2008-03-07 20:16:07 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-03-10 19:38:02 -0400
commitb91aac29bb9b7cab34b0297449bd2a16944b83d9 (patch)
treedfe8da51342362245fa39943f57c41c1c0aa4ef9
parent8647af71d623671a020a54d860f77bc0fa2e606e (diff)
PCI Hotplug: Fix small mem leak in IBM Hot Plug Controller Driver
In drivers/pci/hotplug/ibmphp_ebda.c::ebda_rsrc_controller(), storage is allocated with kzalloc() and assigned to 'tmp_slot'. Then lots of stuff, like ->flag, ->supported_speed etc is set in tmp_slot. A bit further down there's then this test : if (!bus_info_ptr1) { rc = -ENODEV; goto error; } At this point, tmp_slot has not been assigned to anything, so when erroring-out we want to free it, but nothing at the 'error:' label free's 'tmp_slot' - and we can't really free 'tmp_slot' at 'error:' since we may jump to that label later when 'tmp_slot' *has* been used and we do not want it freed. So, the only sane option left seems to be to kfree(tmp_slot) just before jumping to the 'error:' label in the one place where this is what actually makes sense. The following patch does just that and thus kills off a tiny potential memory leak. Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/pci/hotplug/ibmphp_ebda.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c
index 600ed7b67ae7..bbccde9f228f 100644
--- a/drivers/pci/hotplug/ibmphp_ebda.c
+++ b/drivers/pci/hotplug/ibmphp_ebda.c
@@ -963,6 +963,7 @@ static int __init ebda_rsrc_controller (void)
963 963
964 bus_info_ptr1 = ibmphp_find_same_bus_num (hpc_ptr->slots[index].slot_bus_num); 964 bus_info_ptr1 = ibmphp_find_same_bus_num (hpc_ptr->slots[index].slot_bus_num);
965 if (!bus_info_ptr1) { 965 if (!bus_info_ptr1) {
966 kfree(tmp_slot);
966 rc = -ENODEV; 967 rc = -ENODEV;
967 goto error; 968 goto error;
968 } 969 }