Skip to content

Commit

Permalink
KVM: Use vfree for memory allocated by vcalloc()/__vcalloc()
Browse files Browse the repository at this point in the history
commit 37b2a65("KVM: use __vcalloc for very large allocations")
replaced kvzalloc()/kvcalloc() with vcalloc(), but didn't replace kvfree()
with vfree().

Signed-off-by: Li RongQing <lirongqing@baidu.com>
Link: https://lore.kernel.org/r/20240131012357.53563-1-lirongqing@baidu.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
  • Loading branch information
Li RongQing authored and Sean Christopherson committed Apr 9, 2024
1 parent b628cb5 commit a952d60
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion arch/x86/kvm/mmu/page_track.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ bool kvm_page_track_write_tracking_enabled(struct kvm *kvm)

void kvm_page_track_free_memslot(struct kvm_memory_slot *slot)
{
kvfree(slot->arch.gfn_write_track);
vfree(slot->arch.gfn_write_track);
slot->arch.gfn_write_track = NULL;
}

Expand Down
6 changes: 3 additions & 3 deletions arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -12731,7 +12731,7 @@ static void memslot_rmap_free(struct kvm_memory_slot *slot)
int i;

for (i = 0; i < KVM_NR_PAGE_SIZES; ++i) {
kvfree(slot->arch.rmap[i]);
vfree(slot->arch.rmap[i]);
slot->arch.rmap[i] = NULL;
}
}
Expand All @@ -12743,7 +12743,7 @@ void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot)
memslot_rmap_free(slot);

for (i = 1; i < KVM_NR_PAGE_SIZES; ++i) {
kvfree(slot->arch.lpage_info[i - 1]);
vfree(slot->arch.lpage_info[i - 1]);
slot->arch.lpage_info[i - 1] = NULL;
}

Expand Down Expand Up @@ -12835,7 +12835,7 @@ static int kvm_alloc_memslot_metadata(struct kvm *kvm,
memslot_rmap_free(slot);

for (i = 1; i < KVM_NR_PAGE_SIZES; ++i) {
kvfree(slot->arch.lpage_info[i - 1]);
vfree(slot->arch.lpage_info[i - 1]);
slot->arch.lpage_info[i - 1] = NULL;
}
return -ENOMEM;
Expand Down
2 changes: 1 addition & 1 deletion virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ static void kvm_destroy_dirty_bitmap(struct kvm_memory_slot *memslot)
if (!memslot->dirty_bitmap)
return;

kvfree(memslot->dirty_bitmap);
vfree(memslot->dirty_bitmap);
memslot->dirty_bitmap = NULL;
}

Expand Down

0 comments on commit a952d60

Please sign in to comment.