diff mbox series

[1/3] pci: Initialize pci_dev->name before use

Message ID 20171123092333.16085-2-peterx@redhat.com
State New
Headers show
Series [1/3] pci: Initialize pci_dev->name before use | expand

Commit Message

Peter Xu Nov. 23, 2017, 9:23 a.m. UTC
From: Alexey Kardashevskiy <aik@ozlabs.ru>

This moves pci_dev->name initialization earlier so
pci_dev->bus_master_as could get a name instead of an empty string.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 hw/pci/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexey Kardashevskiy Nov. 24, 2017, 12:16 a.m. UTC | #1
On 23/11/17 20:23, Peter Xu wrote:
> From: Alexey Kardashevskiy <aik@ozlabs.ru>
> 
> This moves pci_dev->name initialization earlier so
> pci_dev->bus_master_as could get a name instead of an empty string.
> 
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Reviewed-by: Peter Xu <peterx@redhat.com>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> Signed-off-by: Peter Xu <peterx@redhat.com>


It is in upstream:

https://git.qemu.org/?p=qemu.git;a=commitdiff;h=d06bce95ff8c6e2f290db150695f826c3d57324f


> ---
>  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 5ed3c8dca4..b2d139bd9a 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -1030,6 +1030,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);
> @@ -1039,7 +1040,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);
>  
>
Peter Xu Nov. 24, 2017, 6:49 a.m. UTC | #2
On Fri, Nov 24, 2017 at 11:16:53AM +1100, Alexey Kardashevskiy wrote:
> On 23/11/17 20:23, Peter Xu wrote:
> > From: Alexey Kardashevskiy <aik@ozlabs.ru>
> > 
> > This moves pci_dev->name initialization earlier so
> > pci_dev->bus_master_as could get a name instead of an empty string.
> > 
> > Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > Reviewed-by: Peter Xu <peterx@redhat.com>
> > Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> 
> 
> It is in upstream:
> 
> https://git.qemu.org/?p=qemu.git;a=commitdiff;h=d06bce95ff8c6e2f290db150695f826c3d57324f

Again, I thought I was using a relatively new tree but I was not...  Thanks,
diff mbox series

Patch

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 5ed3c8dca4..b2d139bd9a 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1030,6 +1030,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);
@@ -1039,7 +1040,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);