]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA/irdma: Return EINVAL for invalid arp index error
authorTatyana Nikolova <tatyana.e.nikolova@intel.com>
Mon, 16 Mar 2026 18:39:46 +0000 (13:39 -0500)
committerLeon Romanovsky <leonro@nvidia.com>
Wed, 18 Mar 2026 10:20:53 +0000 (06:20 -0400)
When rdma_connect() fails due to an invalid arp index, user space rdma core
reports ENOMEM which is confusing. Modify irdma_make_cm_node() to return the
correct error code.

Fixes: 146b9756f14c ("RDMA/irdma: Add connection manager")
Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/irdma/cm.c

index 13b24ffca265e0a63bcdc3374e9e98c6e04c5ab7..91c0e7298283627118abf2e8bd6a87904144a088 100644 (file)
@@ -2241,11 +2241,12 @@ irdma_make_cm_node(struct irdma_cm_core *cm_core, struct irdma_device *iwdev,
        int oldarpindex;
        int arpindex;
        struct net_device *netdev = iwdev->netdev;
+       int ret;
 
        /* create an hte and cm_node for this instance */
        cm_node = kzalloc_obj(*cm_node, GFP_ATOMIC);
        if (!cm_node)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        /* set our node specific transport info */
        cm_node->ipv4 = cm_info->ipv4;
@@ -2348,8 +2349,10 @@ irdma_make_cm_node(struct irdma_cm_core *cm_core, struct irdma_device *iwdev,
                        arpindex = -EINVAL;
        }
 
-       if (arpindex < 0)
+       if (arpindex < 0) {
+               ret = -EINVAL;
                goto err;
+       }
 
        ether_addr_copy(cm_node->rem_mac,
                        iwdev->rf->arp_table[arpindex].mac_addr);
@@ -2360,7 +2363,7 @@ irdma_make_cm_node(struct irdma_cm_core *cm_core, struct irdma_device *iwdev,
 err:
        kfree(cm_node);
 
-       return NULL;
+       return ERR_PTR(ret);
 }
 
 static void irdma_destroy_connection(struct irdma_cm_node *cm_node)
@@ -3021,8 +3024,8 @@ static int irdma_create_cm_node(struct irdma_cm_core *cm_core,
 
        /* create a CM connection node */
        cm_node = irdma_make_cm_node(cm_core, iwdev, cm_info, NULL);
-       if (!cm_node)
-               return -ENOMEM;
+       if (IS_ERR(cm_node))
+               return PTR_ERR(cm_node);
 
        /* set our node side to client (active) side */
        cm_node->tcp_cntxt.client = 1;
@@ -3219,9 +3222,9 @@ void irdma_receive_ilq(struct irdma_sc_vsi *vsi, struct irdma_puda_buf *rbuf)
                cm_info.cm_id = listener->cm_id;
                cm_node = irdma_make_cm_node(cm_core, iwdev, &cm_info,
                                             listener);
-               if (!cm_node) {
+               if (IS_ERR(cm_node)) {
                        ibdev_dbg(&cm_core->iwdev->ibdev,
-                                 "CM: allocate node failed\n");
+                                 "CM: allocate node failed ret=%ld\n", PTR_ERR(cm_node));
                        refcount_dec(&listener->refcnt);
                        return;
                }