|
|
3bcb62 |
From 8bb25f86ea1976bc8dcc009be37e7c779d131811 Mon Sep 17 00:00:00 2001
|
|
|
3bcb62 |
From: Patrisious Haddad <phaddad@nvidia.com>
|
|
|
3bcb62 |
Date: Mon, 26 Oct 2020 10:38:13 +0200
|
|
|
3bcb62 |
Subject: [PATCH] udaddy: Fix create_reply_ah error flow
|
|
|
3bcb62 |
|
|
|
3bcb62 |
[ Upstream commit 2213fe559b74d4281f9d42e425dfbd7e0f582a67 ]
|
|
|
3bcb62 |
|
|
|
3bcb62 |
Return error in case create_reply_ah() fails to create AH.
|
|
|
3bcb62 |
|
|
|
3bcb62 |
Fixes: a7eb7efbf69f ("r8077: Add support for UD QPs to the RDMA CM library, along with a goofy test program")
|
|
|
3bcb62 |
Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
|
|
|
3bcb62 |
Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
|
|
|
3bcb62 |
Signed-off-by: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
|
|
|
3bcb62 |
---
|
|
|
3bcb62 |
librdmacm/examples/udaddy.c | 19 ++++++++++++++-----
|
|
|
3bcb62 |
1 file changed, 14 insertions(+), 5 deletions(-)
|
|
|
3bcb62 |
|
|
|
3bcb62 |
diff --git a/librdmacm/examples/udaddy.c b/librdmacm/examples/udaddy.c
|
|
|
3bcb62 |
index 9283caa4971f..9f911289da3c 100644
|
|
|
3bcb62 |
--- a/librdmacm/examples/udaddy.c
|
|
|
3bcb62 |
+++ b/librdmacm/examples/udaddy.c
|
|
|
3bcb62 |
@@ -449,23 +449,27 @@ static void destroy_nodes(void)
|
|
|
3bcb62 |
free(test.nodes);
|
|
|
3bcb62 |
}
|
|
|
3bcb62 |
|
|
|
3bcb62 |
-static void create_reply_ah(struct cmatest_node *node, struct ibv_wc *wc)
|
|
|
3bcb62 |
+static int create_reply_ah(struct cmatest_node *node, struct ibv_wc *wc)
|
|
|
3bcb62 |
{
|
|
|
3bcb62 |
struct ibv_qp_attr attr;
|
|
|
3bcb62 |
struct ibv_qp_init_attr init_attr;
|
|
|
3bcb62 |
|
|
|
3bcb62 |
node->ah = ibv_create_ah_from_wc(node->pd, wc, node->mem,
|
|
|
3bcb62 |
node->cma_id->port_num);
|
|
|
3bcb62 |
+ if (!node->ah)
|
|
|
3bcb62 |
+ return -1;
|
|
|
3bcb62 |
node->remote_qpn = be32toh(wc->imm_data);
|
|
|
3bcb62 |
|
|
|
3bcb62 |
- ibv_query_qp(node->cma_id->qp, &attr, IBV_QP_QKEY, &init_attr);
|
|
|
3bcb62 |
+ if (ibv_query_qp(node->cma_id->qp, &attr, IBV_QP_QKEY, &init_attr))
|
|
|
3bcb62 |
+ return -1;
|
|
|
3bcb62 |
node->remote_qkey = attr.qkey;
|
|
|
3bcb62 |
+ return 0;
|
|
|
3bcb62 |
}
|
|
|
3bcb62 |
|
|
|
3bcb62 |
static int poll_cqs(void)
|
|
|
3bcb62 |
{
|
|
|
3bcb62 |
struct ibv_wc wc[8];
|
|
|
3bcb62 |
- int done, i, ret;
|
|
|
3bcb62 |
+ int done, i, ret, rc;
|
|
|
3bcb62 |
|
|
|
3bcb62 |
for (i = 0; i < connections; i++) {
|
|
|
3bcb62 |
if (!test.nodes[i].connected)
|
|
|
3bcb62 |
@@ -478,8 +482,13 @@ static int poll_cqs(void)
|
|
|
3bcb62 |
return ret;
|
|
|
3bcb62 |
}
|
|
|
3bcb62 |
|
|
|
3bcb62 |
- if (ret && !test.nodes[i].ah)
|
|
|
3bcb62 |
- create_reply_ah(&test.nodes[i], wc);
|
|
|
3bcb62 |
+ if (ret && !test.nodes[i].ah) {
|
|
|
3bcb62 |
+ rc = create_reply_ah(&test.nodes[i], wc);
|
|
|
3bcb62 |
+ if (rc) {
|
|
|
3bcb62 |
+ printf("udaddy: failed to create reply AH\n");
|
|
|
3bcb62 |
+ return rc;
|
|
|
3bcb62 |
+ }
|
|
|
3bcb62 |
+ }
|
|
|
3bcb62 |
}
|
|
|
3bcb62 |
}
|
|
|
3bcb62 |
return 0;
|
|
|
3bcb62 |
--
|
|
|
3bcb62 |
2.25.4
|
|
|
3bcb62 |
|