Skip to content

Commit

Permalink
vfio/pci: Handle subsystem realpath() returning NULL
Browse files Browse the repository at this point in the history
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: 238e917 ("vfio/ccw/pci: Allow devices to opt-in for ballooning")
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
  • Loading branch information
awilliam committed Aug 23, 2018
1 parent 3392fbe commit a1c0f88
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hw/vfio/pci.c
Expand Up @@ -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);
Expand Down

0 comments on commit a1c0f88

Please sign in to comment.