iommu/intel-iommu: fix memory leak in intel_iommu_put_resv_regions()
PATCH 1/1 iommu/intel-iommu: 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.
--- drivers/iommu/intel-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +1 -1
@@ -5295,7 +5295,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); } }
Signature · 1 line
2.16.4
Hi Gerald,
Quoted 9 lines · Gerald Schaefer
Commit
9d3a4de4cb8d("iommu: Disambiguate MSI region types") changed the reserved region type inintel_iommu_get_resv_regions()fromIOMMU_RESV_RESERVEDtoIOMMU_RESV_MSI, but it forgot to also change the type inintel_iommu_put_resv_regions().This leads to a memory leak, because now the check in
intel_iommu_put_resv_regions()forIOMMU_RESV_RESERVEDwill never be true, and no allocated regions will be freed.
Quoted 6 lines
Fix this by changing the region type in
intel_iommu_put_resv_regions()toIOMMU_RESV_MSI, matching the type of the allocated regions.Fixes 9d3a4de4cb8d ("iommu: Disambiguate MSI region types")Cc <[email protected]> # v4.11+Signed-off-by Gerald Schaefer <[email protected]>
Thanks
Eric
Quoted 18 lines
--- drivers/iommu/intel-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/intel-iommu.c +1
-1@@ -5295,7 +5295,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); } }
Joerg Roedel
AppliedQuoted 12 lines · Gerald Schaefer
Commit
9d3a4de4cb8d("iommu: Disambiguate MSI region types") changed the reserved region type inintel_iommu_get_resv_regions()fromIOMMU_RESV_RESERVEDtoIOMMU_RESV_MSI, but it forgot to also change the type inintel_iommu_put_resv_regions().This leads to a memory leak, because now the check in
intel_iommu_put_resv_regions()forIOMMU_RESV_RESERVEDwill never be true, and no allocated regions will be freed.Fix this by changing the region type in
intel_iommu_put_resv_regions()toIOMMU_RESV_MSI, matching the type of the allocated regions.
Quoted 6 lines
Fixes 9d3a4de4cb8d ("iommu: Disambiguate MSI region types")Cc <[email protected]> # v4.11+Signed-off-by Gerald Schaefer <[email protected]>--- drivers/iommu/intel-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.