Commit 30a759b6 authored by Roman Kagan's avatar Roman Kagan Committed by Eduardo Habkost
Browse files

hw/hyperv: fix NULL dereference with pure-kvm SynIC



When started in compat configuration of SynIC, e.g.

qemu-system-x86_64 -machine pc-i440fx-2.10,accel=kvm \
 -cpu host,-vmx,hv-relaxed,hv_spinlocks=0x1fff,hv-vpindex,hv-synic

or explicitly

qemu-system-x86_64 -enable-kvm -cpu host,hv-synic,x-hv-synic-kvm-only=on

QEMU crashes in hyperv_synic_reset() trying to access the non-present
qobject for SynIC.

Add the missing check for NULL.

Reported-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Reported-by: default avatarIgor Mammedov <imammedo@redhat.com>
Fixes: 9b4cf107
Fixes: 4a93722f
Signed-off-by: default avatarRoman Kagan <rkagan@virtuozzo.com>
Message-Id: <20181126152836.25379-1-rkagan@virtuozzo.com>
Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
parent aec5e9c3
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -136,7 +136,11 @@ void hyperv_synic_add(CPUState *cs)

void hyperv_synic_reset(CPUState *cs)
{
    device_reset(DEVICE(get_synic(cs)));
    SynICState *synic = get_synic(cs);

    if (synic) {
        device_reset(DEVICE(synic));
    }
}

static const TypeInfo synic_type_info = {