Commit b8f4fe66 authored by Muli Ben-Yehuda's avatar Muli Ben-Yehuda Committed by Andi Kleen

[PATCH] Calgary IOMMU: fix error path memleak in calgary_free_tar

We were freeing the iommu_table and leaking the bitmap pages. Also
rename it to calgary_free_bus, which is more accurate.
Signed-off-by: default avatarMuli Ben-Yehuda <muli@il.ibm.com>
Signed-off-by: default avatarJon Mason <jdmason@us.ibm.com>
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
parent 9f2dc46d
...@@ -658,11 +658,12 @@ static int __init calgary_setup_tar(struct pci_dev *dev, void __iomem *bbar) ...@@ -658,11 +658,12 @@ static int __init calgary_setup_tar(struct pci_dev *dev, void __iomem *bbar)
return 0; return 0;
} }
static void __init calgary_free_tar(struct pci_dev *dev) static void __init calgary_free_bus(struct pci_dev *dev)
{ {
u64 val64; u64 val64;
struct iommu_table *tbl = dev->sysdata; struct iommu_table *tbl = dev->sysdata;
void __iomem *target; void __iomem *target;
unsigned int bitmapsz;
target = calgary_reg(tbl->bbar, tar_offset(dev->bus->number)); target = calgary_reg(tbl->bbar, tar_offset(dev->bus->number));
val64 = be64_to_cpu(readq(target)); val64 = be64_to_cpu(readq(target));
...@@ -670,8 +671,15 @@ static void __init calgary_free_tar(struct pci_dev *dev) ...@@ -670,8 +671,15 @@ static void __init calgary_free_tar(struct pci_dev *dev)
writeq(cpu_to_be64(val64), target); writeq(cpu_to_be64(val64), target);
readq(target); /* flush */ readq(target); /* flush */
bitmapsz = tbl->it_size / BITS_PER_BYTE;
free_pages((unsigned long)tbl->it_map, get_order(bitmapsz));
tbl->it_map = NULL;
kfree(tbl); kfree(tbl);
dev->sysdata = NULL; dev->sysdata = NULL;
/* Can't free bootmem allocated memory after system is up :-( */
bus_info[dev->bus->number].tce_space = NULL;
} }
static void calgary_watchdog(unsigned long data) static void calgary_watchdog(unsigned long data)
...@@ -853,7 +861,7 @@ error: ...@@ -853,7 +861,7 @@ error:
if (!bus_info[dev->bus->number].tce_space && !translate_empty_slots) if (!bus_info[dev->bus->number].tce_space && !translate_empty_slots)
continue; continue;
calgary_disable_translation(dev); calgary_disable_translation(dev);
calgary_free_tar(dev); calgary_free_bus(dev);
pci_dev_put(dev); pci_dev_put(dev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment