[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] vfio/pci: Handle subsystem realpath() returning NUL
From: |
Alex Williamson |
Subject: |
[Qemu-devel] [PATCH] vfio/pci: Handle subsystem realpath() returning NULL |
Date: |
Mon, 20 Aug 2018 08:49:03 -0600 |
User-agent: |
StGit/0.18-136-gffd7-dirty |
Fix error reported by Coverity where realpath can return NULL,
resulting in a segfault in strcmp(). This should never happen given
that we're working through regularly structured sysfs paths, but
trivial enough to easily avoid.
Signed-off-by: Alex Williamson <address@hidden>
---
hw/vfio/pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 056f3a887a8f..866f0deeb7eb 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2879,7 +2879,7 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
tmp = g_strdup_printf("%s/subsystem", vdev->vbasedev.sysfsdev);
subsys = realpath(tmp, NULL);
g_free(tmp);
- is_mdev = (strcmp(subsys, "/sys/bus/mdev") == 0);
+ is_mdev = subsys && (strcmp(subsys, "/sys/bus/mdev") == 0);
free(subsys);
trace_vfio_mdev(vdev->vbasedev.name, is_mdev);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH] vfio/pci: Handle subsystem realpath() returning NULL,
Alex Williamson <=