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