summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Schaefer <gerald.schaefer@de.ibm.com>2019-01-16 20:11:44 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-02-06 17:27:40 +0100
commit4b3d0c4a12fb7dc794d5f0a84a6634a9bfa728ab (patch)
treed26f2e9ced42fe56ab7488dcf53ef7e7ed91d187
parentde881e65ba81d3ddf220d8c0513c03d5841511fc (diff)
downloadlinux-4b3d0c4a12fb7dc794d5f0a84a6634a9bfa728ab.tar.gz
linux-4b3d0c4a12fb7dc794d5f0a84a6634a9bfa728ab.tar.bz2
linux-4b3d0c4a12fb7dc794d5f0a84a6634a9bfa728ab.zip
iommu/vt-d: Fix memory leak in intel_iommu_put_resv_regions()
commit 198bc3252ea3a45b0c5d500e6a5b91cfdd08f001 upstream. Commit 9d3a4de4cb8d ("iommu: Disambiguate MSI region types") changed the reserved region type in intel_iommu_get_resv_regions() from IOMMU_RESV_RESERVED to IOMMU_RESV_MSI, but it forgot to also change the type in intel_iommu_put_resv_regions(). This leads to a memory leak, because now the check in intel_iommu_put_resv_regions() for IOMMU_RESV_RESERVED will never be true, and no allocated regions will be freed. Fix this by changing the region type in intel_iommu_put_resv_regions() to IOMMU_RESV_MSI, matching the type of the allocated regions. Fixes: 9d3a4de4cb8d ("iommu: Disambiguate MSI region types") Cc: <stable@vger.kernel.org> # v4.11+ Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/iommu/intel-iommu.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index f3afab82f3ee..7ec9c6739170 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -5204,7 +5204,7 @@ static void intel_iommu_put_resv_regions(struct device *dev,
struct iommu_resv_region *entry, *next;
list_for_each_entry_safe(entry, next, head, list) {
- if (entry->type == IOMMU_RESV_RESERVED)
+ if (entry->type == IOMMU_RESV_MSI)
kfree(entry);
}
}