Re: [PATCH v8 02/13] KVM: s390: Do not free SCA if it was not allocated

Christian Borntraeger <[email protected]> Mon, 3 Aug 2026 16:08:22 +0200
Newsgroups org.kernel.vger.linux-s390,org.kernel.vger.kvm,org.kernel.vger.linux-kernel
Message-ID <[email protected]>

Am 03.08.26 um 14:40 schrieb Claudio Imbrenda:
> If VM creation fails early in kvm_arch_init_vm(), the cleanup code
> tries to free up the SCA, even though the address is 0. Due to using
> free_pages_exact(), only the first page is skipped, accidentally
> freeing pages 1, 2, and 3.
> 
> Fix by checking whether the pointer is NULL before attempting to free
> the SCA in sca_dispose().
> 
> Fixes: e72753ed1267 ("KVM: s390: Use ESCA instead of BSCA at VM init")
> Signed-off-by: Claudio Imbrenda <[email protected]>

Reviewed-by: Christian Borntraeger <[email protected]>

> ---
>   arch/s390/kvm/kvm-s390.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index f86b4b0b356f..1b3290a5ad1a 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -3247,7 +3247,8 @@ static void kvm_s390_crypto_init(struct kvm *kvm)
>   
>   static void sca_dispose(struct kvm *kvm)
>   {
> -	free_pages_exact(kvm->arch.sca, sizeof(*kvm->arch.sca));
> +	if (kvm->arch.sca)
> +		free_pages_exact(kvm->arch.sca, sizeof(*kvm->arch.sca));
>   	kvm->arch.sca = NULL;
>   }
>