diff mbox series

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

Message ID 20240723142204.758796-1-dakr@kernel.org (mailing list archive)
State New, archived
Headers show
Series KVM: arm64: free kvm->arch.nested_mmus with kvfree() | expand

Commit Message

Danilo Krummrich July 23, 2024, 2:20 p.m. UTC
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")
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
 arch/arm64/kvm/nested.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


base-commit: 66ebbdfdeb093e097399b1883390079cd4c3022b

Comments

Marc Zyngier July 23, 2024, 3 p.m. UTC | #1
On Tue, 23 Jul 2024 15:20:52 +0100,
Danilo Krummrich <dakr@kernel.org> wrote:
> 
> 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")
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
> ---
>  arch/arm64/kvm/nested.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c
> index de789e0f1ae9..bab27f9d8cc6 100644
> --- a/arch/arm64/kvm/nested.c
> +++ b/arch/arm64/kvm/nested.c
> @@ -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.

Reviewed-by: Marc Zyngier <maz@kernel.org>

	M.
Oliver Upton Aug. 5, 2024, 10:11 p.m. UTC | #2
On Tue, 23 Jul 2024 16:20:52 +0200, Danilo Krummrich wrote:
> kvm->arch.nested_mmus is allocated with kvrealloc(), hence free it with
> kvfree() instead of kfree().
> 
> 

Vacation + catching a bug while I was out got me waaaaay behind. Sorry
I hadn't grabbed this yet.

Applied to kvmarm/fixes, thanks!

[1/1] KVM: arm64: free kvm->arch.nested_mmus with kvfree()
      https://git.kernel.org/kvmarm/kvmarm/c/32b9a52f88a5

--
Best,
Oliver
diff mbox series

Patch

diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c
index de789e0f1ae9..bab27f9d8cc6 100644
--- a/arch/arm64/kvm/nested.c
+++ b/arch/arm64/kvm/nested.c
@@ -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);