rdma-core/SOURCES/0001-udaddy-Fix-create_repl...

72 lines
2.1 KiB
Diff

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