intel-iommu: Fix leaks in pagetable freeing
authorAlex Williamson <alex.williamson@redhat.com>
Sat, 15 Jun 2013 16:27:19 +0000 (10:27 -0600)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 26 Oct 2013 20:05:58 +0000 (21:05 +0100)
commitf4dc9ffcb6227d10335af8be77c0f9a1a43f2578
treef5dfb41e0f6ed4bf1ddd9428ef9ec8ad2683c13d
parentef9ba15dbf44cf0d84131f72f7e72e6af3d0a232
intel-iommu: Fix leaks in pagetable freeing

commit 3269ee0bd6686baf86630300d528500ac5b516d7 upstream.

At best the current code only seems to free the leaf pagetables and
the root.  If you're unlucky enough to have a large gap (like any
QEMU guest with more than 3G of memory), only the first chunk of leaf
pagetables are freed (plus the root).  This is a massive memory leak.
This patch re-writes the pagetable freeing function to use a
recursive algorithm and manages to not only free all the pagetables,
but does it without any apparent performance loss versus the current
broken version.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/iommu/intel-iommu.c