Skip to contentSkip to conversation

KVM: arm64: free kvm->arch.nested_mmus with kvfree()

PATCH Applied Danilo Krummrich 3 participants 3 messages Jul 23, 2024 – Aug 5, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: arm64: free kvm->arch.nested_mmus with kvfree()

kvm->arch.nested_mmus is allocated with kvrealloc(), hence free it with kvfree() instead of kfree().

Fixes 4f128f8e1aaa ("KVM: arm64: nv: Support multiple nested Stage-2 mmu structures")
---
 arch/arm64/kvm/nested.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/nested.c +1 -1
index de789e0f1ae9..bab27f9d8cc6 100644
@@ -786,7 +786,7 @@ void kvm_arch_flush_shadow_all(struct kvm *kvm)
 		if (!WARN_ON(atomic_read(&mmu->refcnt)))
 			kvm_free_stage2_pgd(mmu);
 	}
-	kfree(kvm->arch.nested_mmus);
+	kvfree(kvm->arch.nested_mmus);
 	kvm->arch.nested_mmus = NULL;
 	kvm->arch.nested_mmus_size = 0;
 	kvm_uninit_stage2_mmu(kvm);

base-commit: 66ebbdfdeb093e097399b1883390079cd4c3022b

Signature · 1 line
2.45.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Danilo Krummrich

kvm->arch.nested_mmus is allocated with kvrealloc(), hence free it with kvfree() instead of kfree().

Fixes 4f128f8e1aaa ("KVM: arm64: nv: Support multiple nested Stage-2 mmu structures")
---
 arch/arm64/kvm/nested.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/nested.c +0 -0
index de789e0f1ae9..bab27f9d8cc6 100644

arch/arm64/kvm/nested.c void kvm_arch_flush_shadow_all(struct kvm *kvm) · line 792

Quoted 8 lines
arch/arm64/kvm/nested.c +1 -1
@@ -786,7 +786,7 @@ void kvm_arch_flush_shadow_all(struct kvm *kvm)
 		if (!WARN_ON(atomic_read(&mmu->refcnt)))
 			kvm_free_stage2_pgd(mmu);
 	}
-	kfree(kvm->arch.nested_mmus);
+	kvfree(kvm->arch.nested_mmus);
 	kvm->arch.nested_mmus = NULL;
 	kvm->arch.nested_mmus_size = 0;
 	kvm_uninit_stage2_mmu(kvm);

Ah, nice catch. Thanks for fixing it.

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.