* [Qemu-devel] [PATCH] pci: correctly initialize bus master as name
@ 2017-03-29 6:38 Jason Wang
2017-03-29 13:43 ` Marcel Apfelbaum
0 siblings, 1 reply; 2+ messages in thread
From: Jason Wang @ 2017-03-29 6:38 UTC (permalink / raw)
To: mst, marcel, qemu-devel; +Cc: Jason Wang
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 initialization")
Fixes: 3716d5902d743 ("pci: introduce a bus master container")
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
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,
pci_dev->devfn = devfn;
pci_dev->requester_id_cache = pci_req_id_cache_get(pci_dev);
+ pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
memory_region_init(&pci_dev->bus_master_container_region, OBJECT(pci_dev),
"bus master container", UINT64_MAX);
@@ -1005,7 +1006,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_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 = 0;
pci_config_alloc(pci_dev);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] pci: correctly initialize bus master as name
2017-03-29 6:38 [Qemu-devel] [PATCH] pci: correctly initialize bus master as name Jason Wang
@ 2017-03-29 13:43 ` Marcel Apfelbaum
0 siblings, 0 replies; 2+ messages in thread
From: Marcel Apfelbaum @ 2017-03-29 13:43 UTC (permalink / raw)
To: Jason Wang, mst, qemu-devel
On 03/29/2017 09:38 AM, Jason Wang wrote:
> 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 initialization")
> Fixes: 3716d5902d743 ("pci: introduce a bus master container")
>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
> 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,
>
> pci_dev->devfn = devfn;
> pci_dev->requester_id_cache = pci_req_id_cache_get(pci_dev);
> + pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
>
> memory_region_init(&pci_dev->bus_master_container_region, OBJECT(pci_dev),
> "bus master container", UINT64_MAX);
> @@ -1005,7 +1006,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_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 = 0;
> pci_config_alloc(pci_dev);
>
>
Hi,
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Thanks,
Marcel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-29 13:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-29 6:38 [Qemu-devel] [PATCH] pci: correctly initialize bus master as name Jason Wang
2017-03-29 13:43 ` Marcel Apfelbaum
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.