]>
Commit | Line | Data |
---|---|---|
ed43125d GKH |
1 | From 198bc3252ea3a45b0c5d500e6a5b91cfdd08f001 Mon Sep 17 00:00:00 2001 |
2 | From: Gerald Schaefer <gerald.schaefer@de.ibm.com> | |
3 | Date: Wed, 16 Jan 2019 20:11:44 +0100 | |
4 | Subject: iommu/vt-d: Fix memory leak in intel_iommu_put_resv_regions() | |
5 | ||
6 | From: Gerald Schaefer <gerald.schaefer@de.ibm.com> | |
7 | ||
8 | commit 198bc3252ea3a45b0c5d500e6a5b91cfdd08f001 upstream. | |
9 | ||
10 | Commit 9d3a4de4cb8d ("iommu: Disambiguate MSI region types") changed | |
11 | the reserved region type in intel_iommu_get_resv_regions() from | |
12 | IOMMU_RESV_RESERVED to IOMMU_RESV_MSI, but it forgot to also change | |
13 | the type in intel_iommu_put_resv_regions(). | |
14 | ||
15 | This leads to a memory leak, because now the check in | |
16 | intel_iommu_put_resv_regions() for IOMMU_RESV_RESERVED will never | |
17 | be true, and no allocated regions will be freed. | |
18 | ||
19 | Fix this by changing the region type in intel_iommu_put_resv_regions() | |
20 | to IOMMU_RESV_MSI, matching the type of the allocated regions. | |
21 | ||
22 | Fixes: 9d3a4de4cb8d ("iommu: Disambiguate MSI region types") | |
23 | Cc: <stable@vger.kernel.org> # v4.11+ | |
24 | Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com> | |
25 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | |
26 | Signed-off-by: Joerg Roedel <jroedel@suse.de> | |
27 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
28 | ||
29 | --- | |
30 | drivers/iommu/intel-iommu.c | 2 +- | |
31 | 1 file changed, 1 insertion(+), 1 deletion(-) | |
32 | ||
33 | --- a/drivers/iommu/intel-iommu.c | |
34 | +++ b/drivers/iommu/intel-iommu.c | |
35 | @@ -5210,7 +5210,7 @@ static void intel_iommu_put_resv_regions | |
36 | struct iommu_resv_region *entry, *next; | |
37 | ||
38 | list_for_each_entry_safe(entry, next, head, list) { | |
39 | - if (entry->type == IOMMU_RESV_RESERVED) | |
40 | + if (entry->type == IOMMU_RESV_MSI) | |
41 | kfree(entry); | |
42 | } | |
43 | } |