Skip to content

Commit 7221f58

Browse files
tatyana-enrleon
authored andcommitted
RDMA/irdma: Return EINVAL for invalid arp index error
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: 146b975 ("RDMA/irdma: Add connection manager") Signed-off-by: Tatyana Nikolova <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 6f52370 commit 7221f58

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

  • drivers/infiniband/hw/irdma

drivers/infiniband/hw/irdma/cm.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,11 +2241,12 @@ irdma_make_cm_node(struct irdma_cm_core *cm_core, struct irdma_device *iwdev,
22412241
int oldarpindex;
22422242
int arpindex;
22432243
struct net_device *netdev = iwdev->netdev;
2244+
int ret;
22442245

22452246
/* create an hte and cm_node for this instance */
22462247
cm_node = kzalloc_obj(*cm_node, GFP_ATOMIC);
22472248
if (!cm_node)
2248-
return NULL;
2249+
return ERR_PTR(-ENOMEM);
22492250

22502251
/* set our node specific transport info */
22512252
cm_node->ipv4 = cm_info->ipv4;
@@ -2348,8 +2349,10 @@ irdma_make_cm_node(struct irdma_cm_core *cm_core, struct irdma_device *iwdev,
23482349
arpindex = -EINVAL;
23492350
}
23502351

2351-
if (arpindex < 0)
2352+
if (arpindex < 0) {
2353+
ret = -EINVAL;
23522354
goto err;
2355+
}
23532356

23542357
ether_addr_copy(cm_node->rem_mac,
23552358
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,
23602363
err:
23612364
kfree(cm_node);
23622365

2363-
return NULL;
2366+
return ERR_PTR(ret);
23642367
}
23652368

23662369
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,
30213024

30223025
/* create a CM connection node */
30233026
cm_node = irdma_make_cm_node(cm_core, iwdev, cm_info, NULL);
3024-
if (!cm_node)
3025-
return -ENOMEM;
3027+
if (IS_ERR(cm_node))
3028+
return PTR_ERR(cm_node);
30263029

30273030
/* set our node side to client (active) side */
30283031
cm_node->tcp_cntxt.client = 1;
@@ -3219,9 +3222,9 @@ void irdma_receive_ilq(struct irdma_sc_vsi *vsi, struct irdma_puda_buf *rbuf)
32193222
cm_info.cm_id = listener->cm_id;
32203223
cm_node = irdma_make_cm_node(cm_core, iwdev, &cm_info,
32213224
listener);
3222-
if (!cm_node) {
3225+
if (IS_ERR(cm_node)) {
32233226
ibdev_dbg(&cm_core->iwdev->ibdev,
3224-
"CM: allocate node failed\n");
3227+
"CM: allocate node failed ret=%ld\n", PTR_ERR(cm_node));
32253228
refcount_dec(&listener->refcnt);
32263229
return;
32273230
}

0 commit comments

Comments
 (0)