diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2010-01-04 09:06:36 +0000 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2010-01-04 09:06:36 +0000 |
commit | 07d20ae391d1cc8acd3f8d0c9bcbd9aa109dced5 (patch) | |
tree | de3dcb00eba840a37a5a6394561facf3cb3bc294 | |
parent | 1c707e89c23fb9810f1e5e42510b79a5f3973d5b (diff) | |
download | xen-07d20ae391d1cc8acd3f8d0c9bcbd9aa109dced5.tar.gz xen-07d20ae391d1cc8acd3f8d0c9bcbd9aa109dced5.tar.bz2 xen-07d20ae391d1cc8acd3f8d0c9bcbd9aa109dced5.zip |
VT-d: fix iommu_domain_destroy
Currently, g2m_ioport list and mapped_rmrrs always won't be released
in iommu_domain_destroy, because the function returns before those
code. It causes potential leak. This patch releases them, and thus
avoid the potential leak.
Signed-off-by: Weidong Han <Weidong.han@intel.com>
-rw-r--r-- | xen/drivers/passthrough/iommu.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index 2ec6d5802e..7558c8729f 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -195,34 +195,25 @@ void iommu_domain_destroy(struct domain *d) if ( !iommu_enabled || !hd->platform_ops ) return; - if ( !need_iommu(d) ) - return; - if ( need_iommu(d) ) { d->need_iommu = 0; hd->platform_ops->teardown(d); - return; } - if ( hd ) + list_for_each_safe ( ioport_list, tmp, &hd->g2m_ioport_list ) { - list_for_each_safe ( ioport_list, tmp, &hd->g2m_ioport_list ) - { - ioport = list_entry(ioport_list, struct g2m_ioport, list); - list_del(&ioport->list); - xfree(ioport); - } - - list_for_each_safe ( rmrr_list, tmp, &hd->mapped_rmrrs ) - { - mrmrr = list_entry(rmrr_list, struct mapped_rmrr, list); - list_del(&mrmrr->list); - xfree(mrmrr); - } + ioport = list_entry(ioport_list, struct g2m_ioport, list); + list_del(&ioport->list); + xfree(ioport); } - return hd->platform_ops->teardown(d); + list_for_each_safe ( rmrr_list, tmp, &hd->mapped_rmrrs ) + { + mrmrr = list_entry(rmrr_list, struct mapped_rmrr, list); + list_del(&mrmrr->list); + xfree(mrmrr); + } } int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn) |