OSDN Git Service

i386: assert 'cs->kvm_state' is not null
authorVitaly Kuznetsov <vkuznets@redhat.com>
Fri, 16 Jul 2021 11:58:51 +0000 (13:58 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 29 Jul 2021 08:15:51 +0000 (10:15 +0200)
commite4adb09f7952fd37b7f1ba3df377d54d0823e682
tree19e69d6fa6862c9f384ae482b6b216250c524299
parent69ea12b19a15ae006521cd5cc0f627f27f738746
i386: assert 'cs->kvm_state' is not null

Coverity reports potential NULL pointer dereference in
get_supported_hv_cpuid_legacy() when 'cs->kvm_state' is NULL. While
'cs->kvm_state' can indeed be NULL in hv_cpuid_get_host(),
kvm_hyperv_expand_features() makes sure that it only happens when
KVM_CAP_SYS_HYPERV_CPUID is supported and KVM_CAP_SYS_HYPERV_CPUID
implies KVM_CAP_HYPERV_CPUID so get_supported_hv_cpuid_legacy() is
never really called. Add asserts to strengthen the protection against
broken KVM behavior.

Coverity: CID 1458243
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20210716115852.418293-1-vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/kvm/kvm.c