qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3] s390: avoid potential null dereference ins390_pcihost_unplug()
@ 2019-01-08 15:11 Li Qiang
  2019-01-08 15:49 ` David Hildenbrand
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Li Qiang @ 2019-01-08 15:11 UTC (permalink / raw)
  To: walling, cohuck, rth, david, pasic, borntraeger
  Cc: qemu-s390x, qemu-devel, Li Qiang

When getting the 'pbdev', the if...else has no default branch.
>From Coverity, the 'pbdev' maybe null when the 'dev' is not
the TYPE_PCI_BRIDGE/TYPE_PCI_DEVICE/TYPE_S390_PCI_DEVICE.
This patch adds a default branch for device plug and unplug.

Spotted by Coverity: CID 1398593

Signed-off-by: Li Qiang <liq3ea@163.com>
---

Change since v2: use g_assert_not_reached for default branch

 hw/s390x/s390-pci-bus.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index 15759b6514..a94700a78c 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -912,6 +912,8 @@ static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
         pbdev->fh = pbdev->idx;
         QTAILQ_INSERT_TAIL(&s->zpci_devs, pbdev, link);
         g_hash_table_insert(s->zpci_table, &pbdev->idx, pbdev);
+    } else {
+        g_assert_not_reached();
     }
 }
 
@@ -956,6 +958,8 @@ static void s390_pcihost_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_S390_PCI_DEVICE)) {
         pbdev = S390_PCI_DEVICE(dev);
         pci_dev = pbdev->pdev;
+    } else {
+        g_assert_not_reached();
     }
 
     switch (pbdev->state) {
-- 
2.17.1

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

* Re: [Qemu-devel] [PATCH v3] s390: avoid potential null dereference ins390_pcihost_unplug()
  2019-01-08 15:11 [Qemu-devel] [PATCH v3] s390: avoid potential null dereference ins390_pcihost_unplug() Li Qiang
@ 2019-01-08 15:49 ` David Hildenbrand
  2019-01-08 16:22 ` Halil Pasic
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2019-01-08 15:49 UTC (permalink / raw)
  To: Li Qiang, walling, cohuck, rth, pasic, borntraeger; +Cc: qemu-s390x, qemu-devel

On 08.01.19 16:11, Li Qiang wrote:
> When getting the 'pbdev', the if...else has no default branch.
> From Coverity, the 'pbdev' maybe null when the 'dev' is not
> the TYPE_PCI_BRIDGE/TYPE_PCI_DEVICE/TYPE_S390_PCI_DEVICE.
> This patch adds a default branch for device plug and unplug.
> 
> Spotted by Coverity: CID 1398593
> 
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
> 
> Change since v2: use g_assert_not_reached for default branch
> 
>  hw/s390x/s390-pci-bus.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
> index 15759b6514..a94700a78c 100644
> --- a/hw/s390x/s390-pci-bus.c
> +++ b/hw/s390x/s390-pci-bus.c
> @@ -912,6 +912,8 @@ static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>          pbdev->fh = pbdev->idx;
>          QTAILQ_INSERT_TAIL(&s->zpci_devs, pbdev, link);
>          g_hash_table_insert(s->zpci_table, &pbdev->idx, pbdev);
> +    } else {
> +        g_assert_not_reached();
>      }
>  }
>  
> @@ -956,6 +958,8 @@ static void s390_pcihost_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
>      } else if (object_dynamic_cast(OBJECT(dev), TYPE_S390_PCI_DEVICE)) {
>          pbdev = S390_PCI_DEVICE(dev);
>          pci_dev = pbdev->pdev;
> +    } else {
> +        g_assert_not_reached();
>      }
>  
>      switch (pbdev->state) {
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

Please note that I'll be sending a bigger unplug rework the next days.

-- 

Thanks,

David / dhildenb

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

* Re: [Qemu-devel] [PATCH v3] s390: avoid potential null dereference ins390_pcihost_unplug()
  2019-01-08 15:11 [Qemu-devel] [PATCH v3] s390: avoid potential null dereference ins390_pcihost_unplug() Li Qiang
  2019-01-08 15:49 ` David Hildenbrand
@ 2019-01-08 16:22 ` Halil Pasic
  2019-01-09 16:07 ` Collin Walling
  2019-01-10 15:18 ` Cornelia Huck
  3 siblings, 0 replies; 5+ messages in thread
From: Halil Pasic @ 2019-01-08 16:22 UTC (permalink / raw)
  To: Li Qiang; +Cc: walling, cohuck, rth, david, borntraeger, qemu-s390x, qemu-devel

On Tue,  8 Jan 2019 07:11:14 -0800
Li Qiang <liq3ea@163.com> wrote:

> When getting the 'pbdev', the if...else has no default branch.
> From Coverity, the 'pbdev' maybe null when the 'dev' is not
> the TYPE_PCI_BRIDGE/TYPE_PCI_DEVICE/TYPE_S390_PCI_DEVICE.
> This patch adds a default branch for device plug and unplug.
> 
> Spotted by Coverity: CID 1398593
> 
> Signed-off-by: Li Qiang <liq3ea@163.com>

Reviewed-by: Halil Pasic <pasic@linux.ibm.com>

[..]

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

* Re: [Qemu-devel] [PATCH v3] s390: avoid potential null dereference ins390_pcihost_unplug()
  2019-01-08 15:11 [Qemu-devel] [PATCH v3] s390: avoid potential null dereference ins390_pcihost_unplug() Li Qiang
  2019-01-08 15:49 ` David Hildenbrand
  2019-01-08 16:22 ` Halil Pasic
@ 2019-01-09 16:07 ` Collin Walling
  2019-01-10 15:18 ` Cornelia Huck
  3 siblings, 0 replies; 5+ messages in thread
From: Collin Walling @ 2019-01-09 16:07 UTC (permalink / raw)
  To: Li Qiang, cohuck, rth, david, pasic, borntraeger; +Cc: qemu-s390x, qemu-devel

On 1/8/19 10:11 AM, Li Qiang wrote:
> When getting the 'pbdev', the if...else has no default branch.
> From Coverity, the 'pbdev' maybe null when the 'dev' is not
> the TYPE_PCI_BRIDGE/TYPE_PCI_DEVICE/TYPE_S390_PCI_DEVICE.
> This patch adds a default branch for device plug and unplug.
> 
> Spotted by Coverity: CID 1398593
> 
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
> 

[...]

Reviewed-by: Collin Walling <walling@linux.ibm.com>

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

* Re: [Qemu-devel] [PATCH v3] s390: avoid potential null dereference ins390_pcihost_unplug()
  2019-01-08 15:11 [Qemu-devel] [PATCH v3] s390: avoid potential null dereference ins390_pcihost_unplug() Li Qiang
                   ` (2 preceding siblings ...)
  2019-01-09 16:07 ` Collin Walling
@ 2019-01-10 15:18 ` Cornelia Huck
  3 siblings, 0 replies; 5+ messages in thread
From: Cornelia Huck @ 2019-01-10 15:18 UTC (permalink / raw)
  To: Li Qiang; +Cc: walling, rth, david, pasic, borntraeger, qemu-s390x, qemu-devel

On Tue,  8 Jan 2019 07:11:14 -0800
Li Qiang <liq3ea@163.com> wrote:

> When getting the 'pbdev', the if...else has no default branch.
> From Coverity, the 'pbdev' maybe null when the 'dev' is not
> the TYPE_PCI_BRIDGE/TYPE_PCI_DEVICE/TYPE_S390_PCI_DEVICE.
> This patch adds a default branch for device plug and unplug.
> 
> Spotted by Coverity: CID 1398593
> 
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
> 
> Change since v2: use g_assert_not_reached for default branch
> 
>  hw/s390x/s390-pci-bus.c | 4 ++++
>  1 file changed, 4 insertions(+)

Thanks, applied.

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

end of thread, other threads:[~2019-01-10 15:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-08 15:11 [Qemu-devel] [PATCH v3] s390: avoid potential null dereference ins390_pcihost_unplug() Li Qiang
2019-01-08 15:49 ` David Hildenbrand
2019-01-08 16:22 ` Halil Pasic
2019-01-09 16:07 ` Collin Walling
2019-01-10 15:18 ` Cornelia Huck

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).