If vfio_add_std_cap() errors then going to out prepends irrelevant
errors for capabilities we haven't attempted to add as we unwind our
recursive stack. Just return error.
Fixes: 7ef165b9a8d9 ("vfio/pci: Pass an error object to vfio_add_capabilities")
Signed-off-by: Alex Williamson <[email protected]>
if (next) {
ret = vfio_add_std_cap(vdev, next, errp);
if (ret) {
- goto out;
+ return ret;
}
} else {
/* Begin the rebuild, use QEMU emulated list bits */
ret = pci_add_capability(pdev, cap_id, pos, size, errp);
break;
}
-out:
+
if (ret < 0) {
error_prepend(errp,
"failed to add PCI capability 0x%x[0x%x]@0x%x: ",