]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: s390: ucontrol: Fix memslot handling
authorClaudio Imbrenda <imbrenda@linux.ibm.com>
Thu, 2 Apr 2026 15:01:35 +0000 (17:01 +0200)
committerClaudio Imbrenda <imbrenda@linux.ibm.com>
Tue, 7 Apr 2026 15:20:42 +0000 (17:20 +0200)
Fix memslots handling for UCONTROL guests. Attempts to delete user
memslots will fail, as they should, without the risk of a NULL pointer
dereference.

Fixes: 413c98f24c63 ("KVM: s390: fake memslot for ucontrol VMs")
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
arch/s390/kvm/kvm-s390.c

index 156878c95e06792cf307441137d88fb6f5dd3dae..63bc496d0c37e8bfe0aa54453a60f96f9a458913 100644 (file)
@@ -5642,7 +5642,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
                                   struct kvm_memory_slot *new,
                                   enum kvm_mr_change change)
 {
-       if (kvm_is_ucontrol(kvm) && new->id < KVM_USER_MEM_SLOTS)
+       if (kvm_is_ucontrol(kvm) && new && new->id < KVM_USER_MEM_SLOTS)
                return -EINVAL;
 
        /* When we are protected, we should not change the memory slots */