From: Gerald Schaefer Date: Wed, 16 Jan 2019 19:11:44 +0000 (+0100) Subject: iommu/vt-d: Fix memory leak in intel_iommu_put_resv_regions() X-Git-Tag: rel_imx_4.19.35_1.1.0~6911 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=7e3251667a1f0cafd0c278b0159e48585e5b6c68;p=linux.git 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: # v4.11+ Signed-off-by: Gerald Schaefer Reviewed-by: Eric Auger Signed-off-by: Joerg Roedel Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 4339177629e3..2b8f5ebae821 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -5230,7 +5230,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); } }