From: Eduardo Habkost Subject: [PULL 2/2] hw/hyperv: fix NULL dereference with pure-kvm SynIC Date: Mon, 26 Nov 2018 18:59:41 -0200 Message-ID: <20181126205941.19021-3-ehabkost@redhat.com> References: <20181126205941.19021-1-ehabkost@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: Eduardo Habkost , kvm@vger.kernel.org, "Michael S. Tsirkin" , Marcelo Tosatti , Roman Kagan , Paolo Bonzini , Richard Henderson To: Peter Maydell , qemu-devel@nongnu.org Return-path: In-Reply-To: <20181126205941.19021-1-ehabkost@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel2=m.gmane.org@nongnu.org Sender: "Qemu-devel" List-Id: kvm.vger.kernel.org From: Roman Kagan When started in compat configuration of SynIC, e.g. qemu-system-x86_64 -machine pc-i440fx-2.10,accel=3Dkvm \ -cpu host,-vmx,hv-relaxed,hv_spinlocks=3D0x1fff,hv-vpindex,hv-synic or explicitly qemu-system-x86_64 -enable-kvm -cpu host,hv-synic,x-hv-synic-kvm-only=3Do= n QEMU crashes in hyperv_synic_reset() trying to access the non-present qobject for SynIC. Add the missing check for NULL. Reported-by: Vitaly Kuznetsov Reported-by: Igor Mammedov Fixes: 9b4cf107b09d18ac30f46fd1c4de8585ccba030c Fixes: 4a93722f9c279184e95b1e1ad775c01deec05065 Signed-off-by: Roman Kagan Message-Id: <20181126152836.25379-1-rkagan@virtuozzo.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Eduardo Habkost --- hw/hyperv/hyperv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c index a28e7249d8..8758635227 100644 --- a/hw/hyperv/hyperv.c +++ b/hw/hyperv/hyperv.c @@ -136,7 +136,11 @@ void hyperv_synic_add(CPUState *cs) =20 void hyperv_synic_reset(CPUState *cs) { - device_reset(DEVICE(get_synic(cs))); + SynICState *synic =3D get_synic(cs); + + if (synic) { + device_reset(DEVICE(synic)); + } } =20 static const TypeInfo synic_type_info =3D { --=20 2.18.0.rc1.1.g3f1ff2140