summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2010-04-10 20:26:55 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-12 15:03:05 -0700
commit70935714dcaf540b6b10328270948a0cda85ab18 (patch)
tree607c4d6b8cf99b65c396dfd527e1d8894239769c
parent28a1bdd6c2e46a94d86929d5283b72808ee147e9 (diff)
downloadlwn-70935714dcaf540b6b10328270948a0cda85ab18.tar.gz
lwn-70935714dcaf540b6b10328270948a0cda85ab18.zip
sparc64: Fix memory leak in pci_register_iommu_region().
[ Upstream commit e182c77cc291456eed127b1472952ddb59a81a9d ] Found by kmemleak. If request_resource() fails, we leak the struct resource we allocated to represent the IOMMU mapping area. This actually happens on sun4v machines because the IOMEM area is only reported sans the IOMMU region, unlike all previous systems. I'll need to fix that at some point, but for now fix the leak. Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--arch/sparc/kernel/pci_common.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/arch/sparc/kernel/pci_common.c b/arch/sparc/kernel/pci_common.c
index b775658a927d..8a000583b5cf 100644
--- a/arch/sparc/kernel/pci_common.c
+++ b/arch/sparc/kernel/pci_common.c
@@ -371,14 +371,19 @@ static void pci_register_iommu_region(struct pci_pbm_info *pbm)
struct resource *rp = kzalloc(sizeof(*rp), GFP_KERNEL);
if (!rp) {
- prom_printf("Cannot allocate IOMMU resource.\n");
- prom_halt();
+ pr_info("%s: Cannot allocate IOMMU resource.\n",
+ pbm->name);
+ return;
}
rp->name = "IOMMU";
rp->start = pbm->mem_space.start + (unsigned long) vdma[0];
rp->end = rp->start + (unsigned long) vdma[1] - 1UL;
rp->flags = IORESOURCE_BUSY;
- request_resource(&pbm->mem_space, rp);
+ if (request_resource(&pbm->mem_space, rp)) {
+ pr_info("%s: Unable to request IOMMU resource.\n",
+ pbm->name);
+ kfree(rp);
+ }
}
}