Blame SOURCES/kvm-vfio-pci-Handle-subsystem-realpath-returning-NULL.patch

ae23c9
From 7a807e50f62f045b13a5b6e28ee02e36e42ad201 Mon Sep 17 00:00:00 2001
ae23c9
From: Alex Williamson <alex.williamson@redhat.com>
ae23c9
Date: Mon, 3 Dec 2018 22:02:00 +0000
ae23c9
Subject: [PATCH 14/16] vfio/pci: Handle subsystem realpath() returning NULL
ae23c9
ae23c9
RH-Author: Alex Williamson <alex.williamson@redhat.com>
ae23c9
Message-id: <154387452062.27651.8506633913988228901.stgit@gimli.home>
ae23c9
Patchwork-id: 83239
ae23c9
O-Subject: [RHEL-8.0 qemu-kvm PATCH 5/7] vfio/pci: Handle subsystem realpath() returning NULL
ae23c9
Bugzilla: 1650272
ae23c9
RH-Acked-by: Peter Xu <peterx@redhat.com>
ae23c9
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
ae23c9
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
ae23c9
RH-Acked-by: David Hildenbrand <david@redhat.com>
ae23c9
ae23c9
Bugzilla: 1650272
ae23c9
ae23c9
Fix error reported by Coverity where realpath can return NULL,
ae23c9
resulting in a segfault in strcmp().  This should never happen given
ae23c9
that we're working through regularly structured sysfs paths, but
ae23c9
trivial enough to easily avoid.
ae23c9
ae23c9
Fixes: 238e91728503 ("vfio/ccw/pci: Allow devices to opt-in for ballooning")
ae23c9
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
ae23c9
(cherry picked from commit a1c0f886496cfb4c336f8eb4155ed424567d653e)
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 hw/vfio/pci.c | 2 +-
ae23c9
 1 file changed, 1 insertion(+), 1 deletion(-)
ae23c9
ae23c9
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
ae23c9
index d43727f..b463661 100644
ae23c9
--- a/hw/vfio/pci.c
ae23c9
+++ b/hw/vfio/pci.c
ae23c9
@@ -2890,7 +2890,7 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
ae23c9
     tmp = g_strdup_printf("%s/subsystem", vdev->vbasedev.sysfsdev);
ae23c9
     subsys = realpath(tmp, NULL);
ae23c9
     g_free(tmp);
ae23c9
-    is_mdev = (strcmp(subsys, "/sys/bus/mdev") == 0);
ae23c9
+    is_mdev = subsys && (strcmp(subsys, "/sys/bus/mdev") == 0);
ae23c9
     free(subsys);
ae23c9
 
ae23c9
     trace_vfio_mdev(vdev->vbasedev.name, is_mdev);
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9