RDMA/cma: Deduplicate error flow in cma_validate_port()
authorChuck Lever <chuck.lever@oracle.com>
Mon, 17 Jul 2023 15:12:25 +0000 (11:12 -0400)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 21 Jul 2023 19:00:18 +0000 (16:00 -0300)
Clean up to prepare for the addition of new logic.

Link: https://lore.kernel.org/r/168960674597.3007.6128252077812202526.stgit@manet.1015granger.net
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/core/cma.c

index 1ee87c3..da54167 100644 (file)
@@ -686,30 +686,31 @@ cma_validate_port(struct ib_device *device, u32 port,
                  struct rdma_id_private *id_priv)
 {
        struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
+       const struct ib_gid_attr *sgid_attr = ERR_PTR(-ENODEV);
        int bound_if_index = dev_addr->bound_dev_if;
-       const struct ib_gid_attr *sgid_attr;
        int dev_type = dev_addr->dev_type;
        struct net_device *ndev = NULL;
 
        if (!rdma_dev_access_netns(device, id_priv->id.route.addr.dev_addr.net))
-               return ERR_PTR(-ENODEV);
+               goto out;
 
        if ((dev_type == ARPHRD_INFINIBAND) && !rdma_protocol_ib(device, port))
-               return ERR_PTR(-ENODEV);
+               goto out;
 
        if ((dev_type != ARPHRD_INFINIBAND) && rdma_protocol_ib(device, port))
-               return ERR_PTR(-ENODEV);
+               goto out;
 
        if (dev_type == ARPHRD_ETHER && rdma_protocol_roce(device, port)) {
                ndev = dev_get_by_index(dev_addr->net, bound_if_index);
                if (!ndev)
-                       return ERR_PTR(-ENODEV);
+                       goto out;
        } else {
                gid_type = IB_GID_TYPE_IB;
        }
 
        sgid_attr = rdma_find_gid_by_port(device, gid, gid_type, port, ndev);
        dev_put(ndev);
+out:
        return sgid_attr;
 }