cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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