[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 01/15] util: vfio-helpers: Fix qemu_vfio_close()
From: |
David Hildenbrand |
Subject: |
[PATCH v3 01/15] util: vfio-helpers: Fix qemu_vfio_close() |
Date: |
Thu, 27 Feb 2020 11:11:51 +0100 |
qemu_vfio_undo_mapping() will decrement the number of mappings and
reshuffle the array elements to fit into the reduced size.
Iterating over all elements like this does not work as expected, let's make
sure to remove all mappings properly.
Reviewed-by: Peter Xu <address@hidden>
Cc: Richard Henderson <address@hidden>
Cc: Paolo Bonzini <address@hidden>
Cc: Eduardo Habkost <address@hidden>
Cc: Marcel Apfelbaum <address@hidden>
Cc: Alex Williamson <address@hidden>
Cc: Stefan Hajnoczi <address@hidden>
Signed-off-by: David Hildenbrand <address@hidden>
---
util/vfio-helpers.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
index 9ec01bfe26..f31aa77ffe 100644
--- a/util/vfio-helpers.c
+++ b/util/vfio-helpers.c
@@ -695,13 +695,11 @@ static void qemu_vfio_reset(QEMUVFIOState *s)
/* Close and free the VFIO resources. */
void qemu_vfio_close(QEMUVFIOState *s)
{
- int i;
-
if (!s) {
return;
}
- for (i = 0; i < s->nr_mappings; ++i) {
- qemu_vfio_undo_mapping(s, &s->mappings[i], NULL);
+ while (s->nr_mappings) {
+ qemu_vfio_undo_mapping(s, &s->mappings[s->nr_mappings - 1], NULL);
}
ram_block_notifier_remove(&s->ram_notifier);
qemu_vfio_reset(s);
--
2.24.1
- [PATCH v3 00/15] Ram blocks with resizeable anonymous allocations under POSIX, David Hildenbrand, 2020/02/27
- [PATCH v3 01/15] util: vfio-helpers: Fix qemu_vfio_close(),
David Hildenbrand <=
- [PATCH v3 02/15] util: vfio-helpers: Remove Error parameter from qemu_vfio_undo_mapping(), David Hildenbrand, 2020/02/27
- [PATCH v3 03/15] util: vfio-helpers: Factor out removal from qemu_vfio_undo_mapping(), David Hildenbrand, 2020/02/27
- [PATCH v3 04/15] exec: Factor out setting ram settings (madvise ...) into qemu_ram_apply_settings(), David Hildenbrand, 2020/02/27
- [PATCH v3 05/15] exec: Reuse qemu_ram_apply_settings() in qemu_ram_remap(), David Hildenbrand, 2020/02/27
- [PATCH v3 06/15] exec: Drop "shared" parameter from ram_block_add(), David Hildenbrand, 2020/02/27
- [PATCH v3 07/15] util/mmap-alloc: Factor out calculation of the pagesize for the guard page, David Hildenbrand, 2020/02/27
- [PATCH v3 08/15] util/mmap-alloc: Factor out reserving of a memory region to mmap_reserve(), David Hildenbrand, 2020/02/27
- [PATCH v3 09/15] util/mmap-alloc: Factor out populating of memory to mmap_populate(), David Hildenbrand, 2020/02/27
- [PATCH v3 10/15] util/mmap-alloc: Prepare for resizeable mmaps, David Hildenbrand, 2020/02/27