This function is a good candidate for VIR_AUTOPTR() conversion.
But this conversion will be easier if we only add @pci device
onto @pcidevs list after it was all set up.
This is no functional change.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
virObjectUnref(pcidevs);
return NULL;
}
- if (virPCIDeviceListAdd(pcidevs, pci) < 0) {
- virPCIDeviceFree(pci);
- virObjectUnref(pcidevs);
- return NULL;
- }
virPCIDeviceSetManaged(pci, hostdev->managed);
virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_XEN);
else
virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_KVM);
+
+ if (virPCIDeviceListAdd(pcidevs, pci) < 0) {
+ virPCIDeviceFree(pci);
+ virObjectUnref(pcidevs);
+ return NULL;
+ }
}
return pcidevs;