summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiaohe Lin <linmiaohe@huawei.com>2019-12-07 17:25:22 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2020-01-21 13:57:18 +0100
commitcad23e72b7742578fad2e4ec8856d376ec8db923 (patch)
treeb8e542850dcc4006c5b6b4461eeb1823dec7fde8
parentdfd146fcae8974d40ef6dcfc047d7a1631e064d9 (diff)
downloadlinux-cad23e72b7742578fad2e4ec8856d376ec8db923.tar.bz2
KVM: x86: check kvm_pit outside kvm_vm_ioctl_reinject()
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>
-rw-r--r--arch/x86/kvm/x86.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 33e165c0351d..e62d2688bfec 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -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;
}