From: Muli Ben-Yehuda <muli@il.ibm.com>
To: ak@suse.de
Cc: jdmason@us.ibm.com, linux-kernel@vger.kernel.org,
discuss@x86-64.org, muli@il.ibm.com
Subject: [PATCH 4 of 7] [x86-64] Calgary IOMMU: fix error path memleak in calgary_free_tar
Date: Tue, 25 Jul 2006 19:56:34 +0300 [thread overview]
Message-ID: <7b1cdbc92f2c618cb59f.1153846594@rhun.haifa.ibm.com> (raw)
In-Reply-To: <patchbomb.1153846590@rhun.haifa.ibm.com>
1 files changed, 10 insertions(+), 2 deletions(-)
arch/x86_64/kernel/pci-calgary.c | 12 ++++++++++--
# HG changeset patch
# User Muli Ben-Yehuda <muli@il.ibm.com>
# Date 1153737408 -10800
# Node ID 7b1cdbc92f2c618cb59feaf472c8b76df875743d
# Parent 4b8fbf25700873a70eff09264e52e9f6c6330c18
[x86-64] 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: Muli Ben-Yehuda <muli@il.ibm.com>
Signed-off-by: Jon Mason <jdmason@us.ibm.com>
diff -r 4b8fbf257008 -r 7b1cdbc92f2c arch/x86_64/kernel/pci-calgary.c
--- a/arch/x86_64/kernel/pci-calgary.c Mon Jul 24 13:30:03 2006 +0300
+++ b/arch/x86_64/kernel/pci-calgary.c Mon Jul 24 13:36:48 2006 +0300
@@ -658,11 +658,12 @@ static int __init calgary_setup_tar(stru
return 0;
}
-static void __init calgary_free_tar(struct pci_dev *dev)
+static void __init calgary_free_bus(struct pci_dev *dev)
{
u64 val64;
struct iommu_table *tbl = dev->sysdata;
void __iomem *target;
+ unsigned int bitmapsz;
target = calgary_reg(tbl->bbar, tar_offset(dev->bus->number));
val64 = be64_to_cpu(readq(target));
@@ -670,8 +671,15 @@ static void __init calgary_free_tar(stru
writeq(cpu_to_be64(val64), target);
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);
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)
@@ -853,7 +861,7 @@ error:
if (!bus_info[dev->bus->number].tce_space && !translate_empty_slots)
continue;
calgary_disable_translation(dev);
- calgary_free_tar(dev);
+ calgary_free_bus(dev);
pci_dev_put(dev);
}
next prev parent reply other threads:[~2006-07-25 16:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-25 16:56 [PATCH 0 of 7] x86-64: Calgary IOMMU updates Muli Ben-Yehuda
2006-07-25 16:56 ` [PATCH 1 of 7] [x86-64] Calgary IOMMU: rearrange 'struct iommu_table' members Muli Ben-Yehuda
2006-07-25 16:56 ` [PATCH 2 of 7] [x86-64] Calgary IOMMU: consolidate per bus data structures Muli Ben-Yehuda
2006-07-25 16:56 ` [PATCH 3 of 7] [x86-64] Calgary IOMMU: break out of pci_find_device_reverse if dev not found Muli Ben-Yehuda
2006-07-25 16:56 ` Muli Ben-Yehuda [this message]
2006-07-25 16:56 ` [PATCH 5 of 7] [x86-64] Calgary IOMMU: fix reference counting of Calgary PCI devices Muli Ben-Yehuda
2006-07-25 16:56 ` [PATCH 6 of 7] [x86-64] Calgary IOMMU: calgary_init_one_nontraslated() can return void Muli Ben-Yehuda
2006-07-25 16:56 ` [PATCH 7 of 7] [x86-64] Calgary IOMMU: save a bit of space in bus_info Muli Ben-Yehuda
2006-07-25 22:25 ` [PATCH 0 of 7] x86-64: Calgary IOMMU updates Andi Kleen
2006-07-25 23:07 ` Jon Mason
2006-07-26 0:06 ` Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7b1cdbc92f2c618cb59f.1153846594@rhun.haifa.ibm.com \
--to=muli@il.ibm.com \
--cc=ak@suse.de \
--cc=discuss@x86-64.org \
--cc=jdmason@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®