qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pcie_sriov: Remove g_new assertion
@ 2023-11-23  7:56 Akihiko Odaki
  2023-11-23 10:05 ` [PATCH-for-8.2] " Philippe Mathieu-Daudé
  2023-11-27  9:11 ` [PATCH] " Cédric Le Goater
  0 siblings, 2 replies; 6+ messages in thread
From: Akihiko Odaki @ 2023-11-23  7:56 UTC (permalink / raw)
  Cc: Akihiko Odaki, Michael S. Tsirkin, Marcel Apfelbaum, qemu-devel

g_new() aborts if the allocation fails so it returns NULL only if the
requested allocation size is zero. register_vfs() makes such an
allocation if NumVFs is zero so it should not assert that g_new()
returns a non-NULL value.

Fixes: 7c0fa8dff8 ("pcie: Add support for Single Root I/O Virtualization (SR/IOV)")
Buglink: https://issues.redhat.com/browse/RHEL-17209
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 hw/pci/pcie_sriov.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c
index 5ef8950940..a1fe65f5d8 100644
--- a/hw/pci/pcie_sriov.c
+++ b/hw/pci/pcie_sriov.c
@@ -178,7 +178,6 @@ static void register_vfs(PCIDevice *dev)
     num_vfs = pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF);
 
     dev->exp.sriov_pf.vf = g_new(PCIDevice *, num_vfs);
-    assert(dev->exp.sriov_pf.vf);
 
     trace_sriov_register_vfs(dev->name, PCI_SLOT(dev->devfn),
                              PCI_FUNC(dev->devfn), num_vfs);
-- 
2.42.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH-for-8.2] pcie_sriov: Remove g_new assertion
  2023-11-23  7:56 [PATCH] pcie_sriov: Remove g_new assertion Akihiko Odaki
@ 2023-11-23 10:05 ` Philippe Mathieu-Daudé
  2023-11-27  9:11 ` [PATCH] " Cédric Le Goater
  1 sibling, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-23 10:05 UTC (permalink / raw)
  To: Akihiko Odaki; +Cc: Michael S. Tsirkin, Marcel Apfelbaum, qemu-devel

On 23/11/23 08:56, Akihiko Odaki wrote:
> g_new() aborts if the allocation fails so it returns NULL only if the
> requested allocation size is zero. register_vfs() makes such an
> allocation if NumVFs is zero so it should not assert that g_new()
> returns a non-NULL value.
> 
> Fixes: 7c0fa8dff8 ("pcie: Add support for Single Root I/O Virtualization (SR/IOV)")
> Buglink: https://issues.redhat.com/browse/RHEL-17209
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
>   hw/pci/pcie_sriov.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c
> index 5ef8950940..a1fe65f5d8 100644
> --- a/hw/pci/pcie_sriov.c
> +++ b/hw/pci/pcie_sriov.c
> @@ -178,7 +178,6 @@ static void register_vfs(PCIDevice *dev)
>       num_vfs = pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF);
>   
>       dev->exp.sriov_pf.vf = g_new(PCIDevice *, num_vfs);
> -    assert(dev->exp.sriov_pf.vf);
>   
>       trace_sriov_register_vfs(dev->name, PCI_SLOT(dev->devfn),
>                                PCI_FUNC(dev->devfn), num_vfs);

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pcie_sriov: Remove g_new assertion
  2023-11-23  7:56 [PATCH] pcie_sriov: Remove g_new assertion Akihiko Odaki
  2023-11-23 10:05 ` [PATCH-for-8.2] " Philippe Mathieu-Daudé
@ 2023-11-27  9:11 ` Cédric Le Goater
  2023-11-30  9:52   ` YangHang Liu
  1 sibling, 1 reply; 6+ messages in thread
From: Cédric Le Goater @ 2023-11-27  9:11 UTC (permalink / raw)
  To: Akihiko Odaki; +Cc: Michael S. Tsirkin, Marcel Apfelbaum, qemu-devel

On 11/23/23 08:56, Akihiko Odaki wrote:
> g_new() aborts if the allocation fails so it returns NULL only if the
> requested allocation size is zero. register_vfs() makes such an
> allocation if NumVFs is zero so it should not assert that g_new()
> returns a non-NULL value.
> 
> Fixes: 7c0fa8dff8 ("pcie: Add support for Single Root I/O Virtualization (SR/IOV)")
> Buglink: https://issues.redhat.com/browse/RHEL-17209
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>


Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.


> ---
>   hw/pci/pcie_sriov.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c
> index 5ef8950940..a1fe65f5d8 100644
> --- a/hw/pci/pcie_sriov.c
> +++ b/hw/pci/pcie_sriov.c
> @@ -178,7 +178,6 @@ static void register_vfs(PCIDevice *dev)
>       num_vfs = pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF);
>   
>       dev->exp.sriov_pf.vf = g_new(PCIDevice *, num_vfs);
> -    assert(dev->exp.sriov_pf.vf);
>   
>       trace_sriov_register_vfs(dev->name, PCI_SLOT(dev->devfn),
>                                PCI_FUNC(dev->devfn), num_vfs);



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pcie_sriov: Remove g_new assertion
  2023-11-27  9:11 ` [PATCH] " Cédric Le Goater
@ 2023-11-30  9:52   ` YangHang Liu
  2023-11-30 15:37     ` Cédric Le Goater
  0 siblings, 1 reply; 6+ messages in thread
From: YangHang Liu @ 2023-11-30  9:52 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: Akihiko Odaki, Michael S. Tsirkin, Marcel Apfelbaum, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1453 bytes --]

After applying this patch, the VM with a igbvf will not crash during reboot.

Tested-by: Yanghang Liu<yanghliu@redhat.com>



On Mon, Nov 27, 2023 at 5:12 PM Cédric Le Goater <clg@redhat.com> wrote:

> On 11/23/23 08:56, Akihiko Odaki wrote:
> > g_new() aborts if the allocation fails so it returns NULL only if the
> > requested allocation size is zero. register_vfs() makes such an
> > allocation if NumVFs is zero so it should not assert that g_new()
> > returns a non-NULL value.
> >
> > Fixes: 7c0fa8dff8 ("pcie: Add support for Single Root I/O Virtualization
> (SR/IOV)")
> > Buglink: https://issues.redhat.com/browse/RHEL-17209
> > Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>
>
> Reviewed-by: Cédric Le Goater <clg@redhat.com>
>
> Thanks,
>
> C.
>
>
> > ---
> >   hw/pci/pcie_sriov.c | 1 -
> >   1 file changed, 1 deletion(-)
> >
> > diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c
> > index 5ef8950940..a1fe65f5d8 100644
> > --- a/hw/pci/pcie_sriov.c
> > +++ b/hw/pci/pcie_sriov.c
> > @@ -178,7 +178,6 @@ static void register_vfs(PCIDevice *dev)
> >       num_vfs = pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF);
> >
> >       dev->exp.sriov_pf.vf = g_new(PCIDevice *, num_vfs);
> > -    assert(dev->exp.sriov_pf.vf);
> >
> >       trace_sriov_register_vfs(dev->name, PCI_SLOT(dev->devfn),
> >                                PCI_FUNC(dev->devfn), num_vfs);
>
>
>

[-- Attachment #2: Type: text/html, Size: 2365 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pcie_sriov: Remove g_new assertion
  2023-11-30  9:52   ` YangHang Liu
@ 2023-11-30 15:37     ` Cédric Le Goater
  2023-11-30 16:12       ` Michael S. Tsirkin
  0 siblings, 1 reply; 6+ messages in thread
From: Cédric Le Goater @ 2023-11-30 15:37 UTC (permalink / raw)
  To: YangHang Liu
  Cc: Akihiko Odaki, Michael S. Tsirkin, Marcel Apfelbaum, qemu-devel,
	Alex Bennée

On 11/30/23 10:52, YangHang Liu wrote:
> After applying this patch, the VM with a igbvf will not crash during reboot.
> 
> Tested-by: Yanghang Liu<yanghliu@redhat.com <mailto:yanghliu@redhat.com>>

Michael, do you have plans to send a PR for -rc3 ?

Thanks,

C.



> 
> On Mon, Nov 27, 2023 at 5:12 PM Cédric Le Goater <clg@redhat.com <mailto:clg@redhat.com>> wrote:
> 
>     On 11/23/23 08:56, Akihiko Odaki wrote:
>      > g_new() aborts if the allocation fails so it returns NULL only if the
>      > requested allocation size is zero. register_vfs() makes such an
>      > allocation if NumVFs is zero so it should not assert that g_new()
>      > returns a non-NULL value.
>      >
>      > Fixes: 7c0fa8dff8 ("pcie: Add support for Single Root I/O Virtualization (SR/IOV)")
>      > Buglink: https://issues.redhat.com/browse/RHEL-17209 <https://issues.redhat.com/browse/RHEL-17209>
>      > Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com <mailto:akihiko.odaki@daynix.com>>
> 
> 
>     Reviewed-by: Cédric Le Goater <clg@redhat.com <mailto:clg@redhat.com>>
> 
>     Thanks,
> 
>     C.
> 
> 
>      > ---
>      >   hw/pci/pcie_sriov.c | 1 -
>      >   1 file changed, 1 deletion(-)
>      >
>      > diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c
>      > index 5ef8950940..a1fe65f5d8 100644
>      > --- a/hw/pci/pcie_sriov.c
>      > +++ b/hw/pci/pcie_sriov.c
>      > @@ -178,7 +178,6 @@ static void register_vfs(PCIDevice *dev)
>      >       num_vfs = pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF);
>      >
>      >       dev->exp.sriov_pf.vf = g_new(PCIDevice *, num_vfs);
>      > -    assert(dev->exp.sriov_pf.vf);
>      >
>      >       trace_sriov_register_vfs(dev->name, PCI_SLOT(dev->devfn),
>      >                                PCI_FUNC(dev->devfn), num_vfs);
> 
> 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pcie_sriov: Remove g_new assertion
  2023-11-30 15:37     ` Cédric Le Goater
@ 2023-11-30 16:12       ` Michael S. Tsirkin
  0 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2023-11-30 16:12 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: YangHang Liu, Akihiko Odaki, Marcel Apfelbaum, qemu-devel,
	Alex Bennée

On Thu, Nov 30, 2023 at 04:37:43PM +0100, Cédric Le Goater wrote:
> On 11/30/23 10:52, YangHang Liu wrote:
> > After applying this patch, the VM with a igbvf will not crash during reboot.
> > 
> > Tested-by: Yanghang Liu<yanghliu@redhat.com <mailto:yanghliu@redhat.com>>
> 
> Michael, do you have plans to send a PR for -rc3 ?
> 
> Thanks,
> 
> C.


Yes.

> 
> 
> > 
> > On Mon, Nov 27, 2023 at 5:12 PM Cédric Le Goater <clg@redhat.com <mailto:clg@redhat.com>> wrote:
> > 
> >     On 11/23/23 08:56, Akihiko Odaki wrote:
> >      > g_new() aborts if the allocation fails so it returns NULL only if the
> >      > requested allocation size is zero. register_vfs() makes such an
> >      > allocation if NumVFs is zero so it should not assert that g_new()
> >      > returns a non-NULL value.
> >      >
> >      > Fixes: 7c0fa8dff8 ("pcie: Add support for Single Root I/O Virtualization (SR/IOV)")
> >      > Buglink: https://issues.redhat.com/browse/RHEL-17209 <https://issues.redhat.com/browse/RHEL-17209>
> >      > Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com <mailto:akihiko.odaki@daynix.com>>
> > 
> > 
> >     Reviewed-by: Cédric Le Goater <clg@redhat.com <mailto:clg@redhat.com>>
> > 
> >     Thanks,
> > 
> >     C.
> > 
> > 
> >      > ---
> >      >   hw/pci/pcie_sriov.c | 1 -
> >      >   1 file changed, 1 deletion(-)
> >      >
> >      > diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c
> >      > index 5ef8950940..a1fe65f5d8 100644
> >      > --- a/hw/pci/pcie_sriov.c
> >      > +++ b/hw/pci/pcie_sriov.c
> >      > @@ -178,7 +178,6 @@ static void register_vfs(PCIDevice *dev)
> >      >       num_vfs = pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF);
> >      >
> >      >       dev->exp.sriov_pf.vf = g_new(PCIDevice *, num_vfs);
> >      > -    assert(dev->exp.sriov_pf.vf);
> >      >
> >      >       trace_sriov_register_vfs(dev->name, PCI_SLOT(dev->devfn),
> >      >                                PCI_FUNC(dev->devfn), num_vfs);
> > 
> > 



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-11-30 16:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-23  7:56 [PATCH] pcie_sriov: Remove g_new assertion Akihiko Odaki
2023-11-23 10:05 ` [PATCH-for-8.2] " Philippe Mathieu-Daudé
2023-11-27  9:11 ` [PATCH] " Cédric Le Goater
2023-11-30  9:52   ` YangHang Liu
2023-11-30 15:37     ` Cédric Le Goater
2023-11-30 16:12       ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).