mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 02:21:52 +09:00
iommu: Fix a leak in iommu_insert_resv_region
[ Upstream commitad0834deda] 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:6c65fb318e("iommu: iommu_get_group_resv_regions") Signed-off-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8231f0a084
commit
6eb4ac7a14
@@ -205,18 +205,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;
|
||||
}
|
||||
@@ -229,7 +232,6 @@ insert:
|
||||
return -ENOMEM;
|
||||
|
||||
list_add_tail(®ion->list, pos);
|
||||
done:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user