Currently, there are two VFIO map functions - primary and secondary -
that use a very similar goto error pattern. However, the label names are
confusing.

Specifcally, for primary, we have three error labels: vfio_res (release
VFIO resource), vfio_dev_fd (close the fd), and map (unmap all the mapped
regions). For secondary, there is vfio_dev (close the fd), and
vfio_dev_fd (unmap all mapped regions).

For consistency, align secondary process function's error labels to match
semantics of how they work in primary process function.

Signed-off-by: Anatoly Burakov <[email protected]>
---
 drivers/bus/pci/linux/pci_vfio.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index bc5c5c2499..a67de6ea02 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -968,7 +968,7 @@ pci_vfio_map_resource_secondary(struct rte_pci_device *dev)
 
        ret = pci_vfio_fill_regions(dev, vfio_dev_fd, &device_info);
        if (ret)
-               goto err_vfio_dev;
+               goto err_vfio_dev_fd;
 
        /* map BARs */
        maps = vfio_res->maps;
@@ -979,14 +979,14 @@ pci_vfio_map_resource_secondary(struct rte_pci_device 
*dev)
                        if (ret < 0) {
                                PCI_LOG(ERR, "%s sparse mapping BAR%i failed: 
%s",
                                        pci_addr, i, strerror(errno));
-                               goto err_vfio_dev_fd;
+                               goto err_map;
                        }
                } else {
                        ret = pci_vfio_mmap_bar(vfio_dev_fd, vfio_res, i, 
MAP_FIXED);
                        if (ret < 0) {
                                PCI_LOG(ERR, "%s mapping BAR%i failed: %s",
                                        pci_addr, i, strerror(errno));
-                               goto err_vfio_dev_fd;
+                               goto err_map;
                        }
                }
 
@@ -995,17 +995,17 @@ pci_vfio_map_resource_secondary(struct rte_pci_device 
*dev)
 
        /* we need save vfio_dev_fd, so it can be used during release */
        if (rte_intr_dev_fd_set(dev->intr_handle, vfio_dev_fd))
-               goto err_vfio_dev_fd;
+               goto err_map;
        if (rte_intr_dev_fd_set(dev->vfio_req_intr_handle, vfio_dev_fd))
-               goto err_vfio_dev_fd;
+               goto err_map;
 
        return 0;
-err_vfio_dev_fd:
+err_map:
        for (j = 0; j < i; j++) {
                if (maps[j].addr)
                        pci_unmap_resource(maps[j].addr, maps[j].size);
        }
-err_vfio_dev:
+err_vfio_dev_fd:
        rte_vfio_release_device(rte_pci_get_sysfs_path(),
                        pci_addr, vfio_dev_fd);
        return -1;
-- 
2.52.0

Reply via email to