iommu/vt-d: Fix memory leak in intel_iommu_put_resv_regions()

This change “iommu/vt-d: Fix memory leak in intel_iommu_put_resv_regions()” in Linux kernel is authored by Gerald Schaefer <gerald.schaefer [at]> on Wed Jan 16 20:11:44 2019 +0100.

iommu/vt-d: Fix memory leak in intel_iommu_put_resv_regions()

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: <> # v4.11+
Signed-off-by: Gerald Schaefer <>
Reviewed-by: Eric Auger <>
Signed-off-by: Joerg Roedel <>

This Linux change may have been applied to various maintained Linux releases and you can find Linux releases including commit 198bc32.

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/iommu/intel-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 2bd9ac2..1457f93 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -5294,7 +5294,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)

The commit for this change in Linux stable tree is 198bc32 (patch).

Leave a Reply

Your email address will not be published. Required fields are marked *