提交 e182c77c 编写于 作者: D David S. Miller

sparc64: Fix memory leak in pci_register_iommu_region().

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: NDavid S. Miller <davem@davemloft.net>
上级 25ad403f
...@@ -371,14 +371,19 @@ static void pci_register_iommu_region(struct pci_pbm_info *pbm) ...@@ -371,14 +371,19 @@ static void pci_register_iommu_region(struct pci_pbm_info *pbm)
struct resource *rp = kzalloc(sizeof(*rp), GFP_KERNEL); struct resource *rp = kzalloc(sizeof(*rp), GFP_KERNEL);
if (!rp) { if (!rp) {
prom_printf("Cannot allocate IOMMU resource.\n"); pr_info("%s: Cannot allocate IOMMU resource.\n",
prom_halt(); pbm->name);
return;
} }
rp->name = "IOMMU"; rp->name = "IOMMU";
rp->start = pbm->mem_space.start + (unsigned long) vdma[0]; rp->start = pbm->mem_space.start + (unsigned long) vdma[0];
rp->end = rp->start + (unsigned long) vdma[1] - 1UL; rp->end = rp->start + (unsigned long) vdma[1] - 1UL;
rp->flags = IORESOURCE_BUSY; 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);
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册