[Qemu-devel] [PATCH qemu v2 REPOST] pci: Initialize pci_dev->name before use

Alexey Kardashevskiy posted 1 patch 6 years, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20171015042452.31714-1-aik@ozlabs.ru
Test checkpatch passed
Test docker passed
Test s390x passed
There is a newer version of this series
hw/pci/pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[Qemu-devel] [PATCH qemu v2 REPOST] pci: Initialize pci_dev->name before use
Posted by Alexey Kardashevskiy 6 years, 5 months ago
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>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---

Changes:
v2:
* fixed mistype in the commit log
* added "rb"
---
 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 1e6fb88eba..05c5f75ef0 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1020,6 +1020,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);
@@ -1029,7 +1030,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.11.0


Re: [Qemu-devel] [PATCH qemu v2 REPOST] pci: Initialize pci_dev->name before use
Posted by Peter Xu 6 years, 5 months ago
On Sun, Oct 15, 2017 at 03:24:52PM +1100, Alexey Kardashevskiy wrote:
> This moves pci_dev->name initialization earlier so
> pci_dev->bus_master_as could get a name instead of an empty string.

Or use "name" instead of "pci_dev->name" when do address_space_init()?
But I think this one works too.

> 
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Maybe "Philippe Mathieu-Daudé"?

> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Reviewed-by: Peter Xu <peterx@redhat.com>

> ---
> 
> Changes:
> v2:
> * fixed mistype in the commit log
> * added "rb"
> ---
>  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 1e6fb88eba..05c5f75ef0 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -1020,6 +1020,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);
> @@ -1029,7 +1030,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.11.0
> 
> 

-- 
Peter Xu

Re: [Qemu-devel] [PATCH qemu v2 REPOST] pci: Initialize pci_dev->name before use
Posted by Alexey Kardashevskiy 6 years, 5 months ago
On 15/10/17 19:01, Peter Xu wrote:
> On Sun, Oct 15, 2017 at 03:24:52PM +1100, Alexey Kardashevskiy wrote:
>> This moves pci_dev->name initialization earlier so
>> pci_dev->bus_master_as could get a name instead of an empty string.
> 
> Or use "name" instead of "pci_dev->name" when do address_space_init()?
> But I think this one works too.
> 
>>
>> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> 
> Maybe "Philippe Mathieu-Daudé"?


Definitely. Repost?


> 
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> 
> Reviewed-by: Peter Xu <peterx@redhat.com>
> 
>> ---
>>
>> Changes:
>> v2:
>> * fixed mistype in the commit log
>> * added "rb"
>> ---
>>  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 1e6fb88eba..05c5f75ef0 100644
>> --- a/hw/pci/pci.c
>> +++ b/hw/pci/pci.c
>> @@ -1020,6 +1020,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);
>> @@ -1029,7 +1030,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.11.0
>>
>>
> 


-- 
Alexey

Re: [Qemu-devel] [PATCH qemu v2 REPOST] pci: Initialize pci_dev->name before use
Posted by Michael S. Tsirkin 6 years, 5 months ago
On Tue, Oct 17, 2017 at 04:00:05PM +1100, Alexey Kardashevskiy wrote:
> On 15/10/17 19:01, Peter Xu wrote:
> > On Sun, Oct 15, 2017 at 03:24:52PM +1100, Alexey Kardashevskiy wrote:
> >> This moves pci_dev->name initialization earlier so
> >> pci_dev->bus_master_as could get a name instead of an empty string.
> > 
> > Or use "name" instead of "pci_dev->name" when do address_space_init()?
> > But I think this one works too.
> > 
> >>
> >> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > 
> > Maybe "Philippe Mathieu-Daudé"?
> 
> 
> Definitely. Repost?


Yes pls.

> 
> > 
> >> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> > 
> > Reviewed-by: Peter Xu <peterx@redhat.com>
> > 
> >> ---
> >>
> >> Changes:
> >> v2:
> >> * fixed mistype in the commit log
> >> * added "rb"
> >> ---
> >>  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 1e6fb88eba..05c5f75ef0 100644
> >> --- a/hw/pci/pci.c
> >> +++ b/hw/pci/pci.c
> >> @@ -1020,6 +1020,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);
> >> @@ -1029,7 +1030,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.11.0
> >>
> >>
> > 
> 
> 
> -- 
> Alexey