From nobody Sun May 5 06:20:24 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149076957120987.69925223980181; Tue, 28 Mar 2017 23:39:31 -0700 (PDT) Received: from localhost ([::1]:56890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ct7GR-0003lF-TC for importer@patchew.org; Wed, 29 Mar 2017 02:39:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ct7Fe-0003NV-BQ for qemu-devel@nongnu.org; Wed, 29 Mar 2017 02:38:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ct7FZ-00072H-Cr for qemu-devel@nongnu.org; Wed, 29 Mar 2017 02:38:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59142) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ct7FZ-00071n-6b for qemu-devel@nongnu.org; Wed, 29 Mar 2017 02:38:33 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0C90DC056793 for ; Wed, 29 Mar 2017 06:38:32 +0000 (UTC) Received: from jason-ThinkPad-T450s.redhat.com (vpn1-7-133.pek2.redhat.com [10.72.7.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F49681C14; Wed, 29 Mar 2017 06:38:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0C90DC056793 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jasowang@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0C90DC056793 From: Jason Wang To: mst@redhat.com, marcel@redhat.com, qemu-devel@nongnu.org Date: Wed, 29 Mar 2017 14:38:22 +0800 Message-Id: <1490769502-4723-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 29 Mar 2017 06:38:32 +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] pci: correctly initialize bus master as name 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: Jason Wang 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" After commit b86eacb804bdb ("hw/pci: delay bus_master_enable_region initialization"), if the device is hotplugged, bus master as will be initialized before pci_dev->name which will cause a NULL address space name. Things will be even worse after 3716d5902d743 ("pci: introduce a bus master container"). So fixing by making sure pci_dev->name is initialized before bus master as. Fixes: b86eacb804bdb ("hw/pci: delay bus_master_enable_region initializatio= n") Fixes: 3716d5902d743 ("pci: introduce a bus master container") Signed-off-by: Jason Wang Reviewed-by: Marcel Apfelbaum --- hw/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index e6b08e1..309afb7 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -996,6 +996,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci= _dev, PCIBus *bus, =20 pci_dev->devfn =3D devfn; pci_dev->requester_id_cache =3D pci_req_id_cache_get(pci_dev); + pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); =20 memory_region_init(&pci_dev->bus_master_container_region, OBJECT(pci_d= ev), "bus master container", UINT64_MAX); @@ -1005,7 +1006,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *p= ci_dev, PCIBus *bus, if (qdev_hotplug) { pci_init_bus_master(pci_dev); } - pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); pci_dev->irq_state =3D 0; pci_config_alloc(pci_dev); =20 --=20 2.7.4