From nobody Sat May 4 06:56:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1518190505957163.22852177168977; Fri, 9 Feb 2018 07:35:05 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 13584C001F17; Fri, 9 Feb 2018 15:35:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 35E7860CA0; Fri, 9 Feb 2018 15:35:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 62BE34A46D; Fri, 9 Feb 2018 15:35:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w19FXkOV001290 for ; Fri, 9 Feb 2018 10:33:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5D10B5D730; Fri, 9 Feb 2018 15:33:46 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-116.phx2.redhat.com [10.3.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A3A85D731; Fri, 9 Feb 2018 15:33:40 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Fri, 9 Feb 2018 10:33:38 -0500 Message-Id: <20180209153338.22031-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: chenhanxiao@gmail.com Subject: [libvirt] [PATCH] qemu: Alter condition to avoid possible NULL deref X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 09 Feb 2018 15:35:04 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Commit 'f0f2a5ec2' neglected to adjust the if condition to split out the possibility that the @watchdog is NULL when altering the message to add detail about the model. Just split out the condition and use previous/original message, but with the new message code. Found by Coverity Signed-off-by: John Ferlan Reviewed-by: Chen Hanxiao --- src/qemu/qemu_hotplug.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index c7bf25eee..3291ce613 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5159,11 +5159,16 @@ qemuDomainDetachWatchdog(virQEMUDriverPtr driver, virDomainWatchdogDefPtr watchdog =3D vm->def->watchdog; qemuDomainObjPrivatePtr priv =3D vm->privateData; =20 + if (!watchdog) { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("watchdog device not present in domain configurat= ion")); + return -1; + } + /* While domains can have up to one watchdog, the one supplied by the = user * doesn't necessarily match the one domain has. Refuse to detach in s= uch * case. */ - if (!(watchdog && - watchdog->model =3D=3D dev->model && + if (!(watchdog->model =3D=3D dev->model && watchdog->action =3D=3D dev->action && virDomainDeviceInfoAddressIsEqual(&dev->info, &watchdog->info)))= { virReportError(VIR_ERR_DEVICE_MISSING, --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list