From nobody Mon Apr 29 07:59:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517811636598764.6196767255595; Sun, 4 Feb 2018 22:20:36 -0800 (PST) Received: from localhost ([::1]:59138 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eia8h-0002vr-7f for importer@patchew.org; Mon, 05 Feb 2018 01:20:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eia7I-00027X-QH for qemu-devel@nongnu.org; Mon, 05 Feb 2018 01:19:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eia7E-0002Jo-Hi for qemu-devel@nongnu.org; Mon, 05 Feb 2018 01:19:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43216) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eia7E-0002IR-Am for qemu-devel@nongnu.org; Mon, 05 Feb 2018 01:18:56 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A1294C0587CC; Mon, 5 Feb 2018 06:18:55 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-130.phx2.redhat.com [10.3.116.130]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF6415D6A3; Mon, 5 Feb 2018 06:18:53 +0000 (UTC) From: P J P To: Qemu Developers Date: Mon, 5 Feb 2018 11:48:49 +0530 Message-Id: <20180205061849.17696-1-ppandit@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 05 Feb 2018 06:18:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] kvm: check dev parameter when updating msi route X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Prasad J Pandit , Guoxiang Niu , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit When updating message signalled interrupt(MSI) route in routine kvm_irqchip_update_msi_route, device parameter could be null. Add check to avoid null dereference. Reported-by: Guoxiang Niu Signed-off-by: Prasad J Pandit --- accel/kvm/kvm-all.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index f290f487a5..cb7613d282 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1167,7 +1167,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, int vector= , PCIDevice *dev) kroute.u.msi.address_lo =3D (uint32_t)msg.address; kroute.u.msi.address_hi =3D msg.address >> 32; kroute.u.msi.data =3D le32_to_cpu(msg.data); - if (pci_available && kvm_msi_devid_required()) { + if (pci_available && dev && kvm_msi_devid_required()) { kroute.flags =3D KVM_MSI_VALID_DEVID; kroute.u.msi.devid =3D pci_requester_id(dev); } @@ -1205,7 +1205,7 @@ int kvm_irqchip_update_msi_route(KVMState *s, int vir= q, MSIMessage msg, kroute.u.msi.address_lo =3D (uint32_t)msg.address; kroute.u.msi.address_hi =3D msg.address >> 32; kroute.u.msi.data =3D le32_to_cpu(msg.data); - if (pci_available && kvm_msi_devid_required()) { + if (pci_available && dev && kvm_msi_devid_required()) { kroute.flags =3D KVM_MSI_VALID_DEVID; kroute.u.msi.devid =3D pci_requester_id(dev); } --=20 2.14.3