* [PATCH] iommu/intel-iommu: fix memory leak in intel_iommu_put_resv_regions()
@ 2019-01-16 19:11 Gerald Schaefer
2019-01-16 20:43 ` Auger Eric
2019-01-22 13:03 ` Joerg Roedel
0 siblings, 2 replies; 3+ messages in thread
From: Gerald Schaefer @ 2019-01-16 19:11 UTC (permalink / raw)
To: Joerg Roedel
Cc: David Woodhouse, Robin Murphy, linux-kernel, iommu, kvm,
Alex Williamson, Eric Auger, Gerald Schaefer
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>
---
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 048b5ab36a02..b83e0f2025bb 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -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);
}
}
--
2.16.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iommu/intel-iommu: fix memory leak in intel_iommu_put_resv_regions()
2019-01-16 19:11 [PATCH] iommu/intel-iommu: fix memory leak in intel_iommu_put_resv_regions() Gerald Schaefer
@ 2019-01-16 20:43 ` Auger Eric
2019-01-22 13:03 ` Joerg Roedel
1 sibling, 0 replies; 3+ messages in thread
From: Auger Eric @ 2019-01-16 20:43 UTC (permalink / raw)
To: Gerald Schaefer, Joerg Roedel
Cc: David Woodhouse, Robin Murphy, linux-kernel, iommu, kvm, Alex Williamson
Hi Gerald,
On 1/16/19 8:11 PM, Gerald Schaefer wrote:
> 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>
Thanks
Eric
> ---
> 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 048b5ab36a02..b83e0f2025bb 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -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);
> }
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iommu/intel-iommu: fix memory leak in intel_iommu_put_resv_regions()
2019-01-16 19:11 [PATCH] iommu/intel-iommu: fix memory leak in intel_iommu_put_resv_regions() Gerald Schaefer
2019-01-16 20:43 ` Auger Eric
@ 2019-01-22 13:03 ` Joerg Roedel
1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2019-01-22 13:03 UTC (permalink / raw)
To: Gerald Schaefer
Cc: David Woodhouse, Robin Murphy, linux-kernel, iommu, kvm,
Alex Williamson, Eric Auger
On Wed, Jan 16, 2019 at 08:11:44PM +0100, Gerald Schaefer wrote:
> 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>
> ---
> drivers/iommu/intel-iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-22 13:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-16 19:11 [PATCH] iommu/intel-iommu: fix memory leak in intel_iommu_put_resv_regions() Gerald Schaefer
2019-01-16 20:43 ` Auger Eric
2019-01-22 13:03 ` Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).