On Wed, Mar 16, 2022 at 12:09:44PM -0600, Ben Gardon wrote: > On Fri, Mar 11, 2022 at 12:02 AM Ricardo Koller <ricarkol@xxxxxxxxxx> wrote: > > > > Deleting a memslot (when freeing a VM) is not closing the backing fd, > > nor it's unmapping the alias mapping. Fix by adding the missing close > > and munmap. > > > > Signed-off-by: Ricardo Koller <ricarkol@xxxxxxxxxx> > > --- > > tools/testing/selftests/kvm/lib/kvm_util.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c > > index ae21564241c8..c25c79f97695 100644 > > --- a/tools/testing/selftests/kvm/lib/kvm_util.c > > +++ b/tools/testing/selftests/kvm/lib/kvm_util.c > > @@ -702,6 +702,12 @@ static void __vm_mem_region_delete(struct kvm_vm *vm, > > sparsebit_free(®ion->unused_phy_pages); > > ret = munmap(region->mmap_start, region->mmap_size); > > TEST_ASSERT(ret == 0, "munmap failed, rc: %i errno: %i", ret, errno); > > + if (region->fd >= 0) { > > + /* There's an extra map if shared memory. */ > > Nit: indentation Will fix in v2. Thanks for the reviews! > > > + ret = munmap(region->mmap_alias, region->mmap_size); > > + TEST_ASSERT(ret == 0, "munmap failed, rc: %i errno: %i", ret, errno); > > + close(region->fd); > > + } > > > > free(region); > > } > > -- > > 2.35.1.723.g4982287a31-goog > >