diff options
author | Eric Auger <eric.auger@redhat.com> | 2019-06-03 09:53:30 +0300 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2019-06-12 11:32:23 +0300 |
commit | ad0834dedaa15c3a176f783c0373f836e44b4700 (patch) | |
tree | de3880f977eebefdbc0860c61c83ccbb035009c3 /drivers/iommu/iommu.c | |
parent | 2de03c11171544bd23e18539f65b3b561d57ff76 (diff) | |
download | linux-ad0834dedaa15c3a176f783c0373f836e44b4700.tar.xz |
iommu: Fix a leak in iommu_insert_resv_region
In case we expand an existing region, we unlink
this latter and insert the larger one. In
that case we should free the original region after
the insertion. Also we can immediately return.
Fixes: 6c65fb318e8b ("iommu: iommu_get_group_resv_regions")
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu/iommu.c')
-rw-r--r-- | drivers/iommu/iommu.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 2fca04c3dbaf..ba0661744a3d 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -237,18 +237,21 @@ static int iommu_insert_resv_region(struct iommu_resv_region *new, pos = pos->next; } else if ((start >= a) && (end <= b)) { if (new->type == type) - goto done; + return 0; else pos = pos->next; } else { if (new->type == type) { phys_addr_t new_start = min(a, start); phys_addr_t new_end = max(b, end); + int ret; list_del(&entry->list); entry->start = new_start; entry->length = new_end - new_start + 1; - iommu_insert_resv_region(entry, regions); + ret = iommu_insert_resv_region(entry, regions); + kfree(entry); + return ret; } else { pos = pos->next; } @@ -261,7 +264,6 @@ insert: return -ENOMEM; list_add_tail(®ion->list, pos); -done: return 0; } |