diff options
| author | Alex Williamson | 2018-08-23 18:45:57 +0200 |
|---|---|---|
| committer | Alex Williamson | 2018-08-23 18:45:57 +0200 |
| commit | a1c0f886496cfb4c336f8eb4155ed424567d653e (patch) | |
| tree | 3513a6ca6bb3831e4508fca9c41d3e3f2ccfa32a /hw | |
| parent | Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-3.1-pull-re... (diff) | |
| download | qemu-a1c0f886496cfb4c336f8eb4155ed424567d653e.tar.gz qemu-a1c0f886496cfb4c336f8eb4155ed424567d653e.tar.xz qemu-a1c0f886496cfb4c336f8eb4155ed424567d653e.zip | |
vfio/pci: Handle subsystem realpath() returning NULL
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.
Fixes: 238e91728503 ("vfio/ccw/pci: Allow devices to opt-in for ballooning")
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'hw')
| -rw-r--r-- | hw/vfio/pci.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 056f3a887a..866f0deeb7 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); |
