Yeah, looking at the patch it's clear the NULL setting was accidentally (?) left off: - if (physPortID) { - if (firstEntryName) { - /* we didn't match the provided phys_port_id, but this - * is probably because phys_port_id isn't implemented - * for this NIC driver, so just return the first - * (probably only) netname we found. - */ - *netname = firstEntryName; - firstEntryName = NULL; - ret = 0; - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not find network device with " - "phys_port_id '%s' under PCI device at %s"), - physPortID, device_link_sysfs_path); - } + if (firstEntryName) { + /* we didn't match the provided phys_port_id / find a + * phys_port_name matching VIR_PF_PHYS_PORT_NAME_REGEX / find + * as many net devices as the value of idx, but this is + * probably because phys_port_id / phys_port_name isn't + * implemented for this NIC driver, so just return the first + * (probably only) netname we found. + */ + *netname = firstEntryName; + ret = 0; either using g_steal_pointer() or just manually setting firstEntryName = NULL (as the code previously did) should fix things, since firstEntryName is automatically freed at the end of the function (since it's declared with g_autofree).