KVM: x86: check kvm_pit outside kvm_vm_ioctl_reinject()
authorMiaohe Lin <linmiaohe@huawei.com>
Sat, 7 Dec 2019 09:25:22 +0000 (17:25 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 21 Jan 2020 12:57:18 +0000 (13:57 +0100)
check kvm_pit outside kvm_vm_ioctl_reinject() to keep codestyle consistent
with other kvm_pit func and prepare for futher cleanups.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c

index 33e165c..e62d268 100644 (file)
@@ -4703,9 +4703,6 @@ static int kvm_vm_ioctl_reinject(struct kvm *kvm,
 {
        struct kvm_pit *pit = kvm->arch.vpit;
 
-       if (!pit)
-               return -ENXIO;
-
        /* pit->pit_state.lock was overloaded to prevent userspace from getting
         * an inconsistent state after running multiple KVM_REINJECT_CONTROL
         * ioctls in parallel.  Use a separate lock if that ioctl isn't rare.
@@ -5072,6 +5069,9 @@ set_identity_unlock:
                r =  -EFAULT;
                if (copy_from_user(&control, argp, sizeof(control)))
                        goto out;
+               r = -ENXIO;
+               if (!kvm->arch.vpit)
+                       goto out;
                r = kvm_vm_ioctl_reinject(kvm, &control);
                break;
        }