GDB backtrace:
Breakpoint 1, virPCIGetVirtualFunctionIndex (pf_sysfs_device_link=0x7fc04400f470
"/sys/bus/pci/devices/0000:03:00.1", vf_sysfs_device_link=<optimized out>,
vf_index=vf_index@entry=0x7fc06897b8f4)
at util/virpci.c:2107
2107 if (virPCIDeviceAddressIsEqual(vf_bdf, virt_fns[i])) {
(gdb) p *vf_bdf
$1 = {domain = 0, bus = 3, slot = 16, function = 1}
(gdb) l
2102 "virtual_functions"), pf_sysfs_device_link);
2103 goto out;
2104 }
2105
2106 for (i = 0; i < num_virt_fns; i++) {
2107 if (virPCIDeviceAddressIsEqual(vf_bdf, virt_fns[i])) {
2108 *vf_index = i;
2109 ret = 0;
2110 break;
2111 }
(gdb) p num_virt_fns
$46 = 2
(gdb) p virt_fns[0]
$48 = (virPCIDeviceAddressPtr) 0x0
(gdb) s
virPCIDeviceAddressIsEqual (bdf2=0x0, bdf1=0x7fc04400f330) at util/virpci.c:1844
1844 (bdf1->slot == bdf2->slot) &&
(gdb) s
Program received signal SIGSEGV, Segmentation fault.
RHBZ:
https://bugzilla.redhat.com/show_bug.cgi?id=957416
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
src/util/virpci.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 97bba74..dda044c 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1897,7 +1897,8 @@ static bool
virPCIDeviceAddressIsEqual(virPCIDeviceAddressPtr bdf1,
virPCIDeviceAddressPtr bdf2)
{
- return ((bdf1->domain == bdf2->domain) &&
+ return (bdf1 && bdf2 &&
+ (bdf1->domain == bdf2->domain) &&
(bdf1->bus == bdf2->bus) &&
(bdf1->slot == bdf2->slot) &&
(bdf1->function == bdf2->function));
--
1.7.1