yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-s390-avoid-potential-null-dereference-in-s390_pcihos.patch

ae23c9
From fae9b269df8dc92176dad05824d8f8e911fb8269 Mon Sep 17 00:00:00 2001
ae23c9
From: Cornelia Huck <cohuck@redhat.com>
ae23c9
Date: Wed, 17 Apr 2019 13:57:26 +0100
ae23c9
Subject: [PATCH 09/24] s390: avoid potential null dereference in
ae23c9
 s390_pcihost_unplug()
ae23c9
MIME-Version: 1.0
ae23c9
Content-Type: text/plain; charset=UTF-8
ae23c9
Content-Transfer-Encoding: 8bit
ae23c9
ae23c9
RH-Author: Cornelia Huck <cohuck@redhat.com>
ae23c9
Message-id: <20190417135741.25297-10-cohuck@redhat.com>
ae23c9
Patchwork-id: 85790
ae23c9
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH v2 09/24] s390: avoid potential null dereference in s390_pcihost_unplug()
ae23c9
Bugzilla: 1699070
ae23c9
RH-Acked-by: David Hildenbrand <david@redhat.com>
ae23c9
RH-Acked-by: Thomas Huth <thuth@redhat.com>
ae23c9
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ae23c9
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
ae23c9
ae23c9
From: Li Qiang <liq3ea@163.com>
ae23c9
ae23c9
When getting the 'pbdev', the if...else has no default branch.
ae23c9
>From Coverity, the 'pbdev' maybe null when the 'dev' is not
ae23c9
the TYPE_PCI_BRIDGE/TYPE_PCI_DEVICE/TYPE_S390_PCI_DEVICE.
ae23c9
This patch adds a default branch for device plug and unplug.
ae23c9
ae23c9
Spotted by Coverity: CID 1398593
ae23c9
ae23c9
Signed-off-by: Li Qiang <liq3ea@163.com>
ae23c9
Message-Id: <20190108151114.33140-1-liq3ea@163.com>
ae23c9
Reviewed-by: David Hildenbrand <david@redhat.com>
ae23c9
Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
ae23c9
Reviewed-by: Collin Walling <walling@linux.ibm.com>
ae23c9
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
ae23c9
(cherry picked from commit 6ed675c92a80ff83638eef5e12d4aac529c12f93)
ae23c9
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 hw/s390x/s390-pci-bus.c | 4 ++++
ae23c9
 1 file changed, 4 insertions(+)
ae23c9
ae23c9
diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
ae23c9
index 9c444b6..486c4b6 100644
ae23c9
--- a/hw/s390x/s390-pci-bus.c
ae23c9
+++ b/hw/s390x/s390-pci-bus.c
ae23c9
@@ -916,6 +916,8 @@ static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
ae23c9
         pbdev->fh = pbdev->idx;
ae23c9
         QTAILQ_INSERT_TAIL(&s->zpci_devs, pbdev, link);
ae23c9
         g_hash_table_insert(s->zpci_table, &pbdev->idx, pbdev);
ae23c9
+    } else {
ae23c9
+        g_assert_not_reached();
ae23c9
     }
ae23c9
 }
ae23c9
 
ae23c9
@@ -960,6 +962,8 @@ static void s390_pcihost_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
ae23c9
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_S390_PCI_DEVICE)) {
ae23c9
         pbdev = S390_PCI_DEVICE(dev);
ae23c9
         pci_dev = pbdev->pdev;
ae23c9
+    } else {
ae23c9
+        g_assert_not_reached();
ae23c9
     }
ae23c9
 
ae23c9
     switch (pbdev->state) {
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9