From: Jarod Wilson <jarod-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Jarod Wilson <jarod-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: [PATCH v2 libmlx5 6/6] fix undefined uuar_index value assignment
Date: Wed, 27 Jul 2016 21:31:55 -0400 [thread overview]
Message-ID: <1469669515-23720-1-git-send-email-jarod@redhat.com> (raw)
In-Reply-To: <1469647047-7544-7-git-send-email-jarod-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
In the case of (attr->comp_mask & MLX5_CREATE_QP_EX2_COMP_MASK) being not
true, uuar_index gets set to resp.uuar_index, but nothing ever initializes
resp.uuar_index.
That said, both this case, and the true case, it looks like uuar_index
never gets assigned to anything but 0. In the true path, resp_ex gets
memset to 0, and then nothing ever sets uuar_index. Not sure what the
intended use was here, but ultimately, uuar_index is always going to be 0
with this patch (0 or undetermined garbage before).
Additionally, I'm not sure if the cmd and resp size parameters passed to
ibv_cmd_create_qp_ex() are correct, but they're at least larger than they
might be, which should be fine. I think. But I'm just guessing here.
v2: only check flag once, save to local var, memset() resp and resp_ex
accordingly within this function.
CC: Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Jarod Wilson <jarod-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
src/verbs.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/verbs.c b/src/verbs.c
index d64e406..c68864a 100644
--- a/src/verbs.c
+++ b/src/verbs.c
@@ -1098,7 +1098,6 @@ static int mlx5_cmd_create_qp_ex(struct ibv_context *context,
struct mlx5_create_qp_ex cmd_ex;
int ret;
- memset(resp, 0, sizeof(*resp));
memset(&cmd_ex, 0, sizeof(cmd_ex));
memcpy(&cmd_ex.ibv_cmd.base, &cmd->ibv_cmd.user_handle,
offsetof(typeof(cmd->ibv_cmd), is_srq) +
@@ -1140,6 +1139,7 @@ struct ibv_qp *create_qp(struct ibv_context *context,
struct ibv_qp *ibqp;
uint32_t usr_idx = 0;
uint32_t uuar_index;
+ uint8_t use_ex2 = 0;
#ifdef MLX5_DEBUG
FILE *fp = ctx->dbg_fp;
#endif
@@ -1147,6 +1147,9 @@ struct ibv_qp *create_qp(struct ibv_context *context,
if (attr->comp_mask & ~MLX5_CREATE_QP_SUP_COMP_MASK)
return NULL;
+ if (attr->comp_mask & MLX5_CREATE_QP_EX2_COMP_MASK)
+ use_ex2 = 1;
+
qp = calloc(1, sizeof(*qp));
if (!qp) {
mlx5_dbg(fp, MLX5_DBG_QP, "\n");
@@ -1156,6 +1159,10 @@ struct ibv_qp *create_qp(struct ibv_context *context,
qp->ibv_qp = ibqp;
memset(&cmd, 0, sizeof(cmd));
+ if (use_ex2)
+ memset(&resp_ex, 0, sizeof(resp_ex));
+ else
+ memset(&resp, 0, sizeof(resp));
qp->wq_sig = qp_sig_enabled();
if (qp->wq_sig)
@@ -1235,7 +1242,7 @@ struct ibv_qp *create_qp(struct ibv_context *context,
cmd.uidx = usr_idx;
}
- if (attr->comp_mask & MLX5_CREATE_QP_EX2_COMP_MASK)
+ if (use_ex2)
ret = mlx5_cmd_create_qp_ex(context, attr, &cmd, qp, &resp_ex);
else
ret = ibv_cmd_create_qp_ex(context, &qp->verbs_qp, sizeof(qp->verbs_qp),
@@ -1246,8 +1253,8 @@ struct ibv_qp *create_qp(struct ibv_context *context,
goto err_free_uidx;
}
- uuar_index = (attr->comp_mask & MLX5_CREATE_QP_EX2_COMP_MASK) ?
- resp_ex.uuar_index : resp.uuar_index;
+ uuar_index = use_ex2 ? resp_ex.uuar_index : resp.uuar_index;
+
if (!ctx->cqe_version) {
if (qp->sq.wqe_cnt || qp->rq.wqe_cnt) {
ret = mlx5_store_qp(ctx, ibqp->qp_num, qp);
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-07-28 1:31 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-27 19:17 [PATCH libmlx5 0/6] libmlx5: fix various coverity/clang issues Jarod Wilson
[not found] ` <1469647047-7544-1-git-send-email-jarod-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-07-27 19:17 ` [PATCH libmlx5 1/6] fix size in malloc of qp->sq.wr_data Jarod Wilson
[not found] ` <1469647047-7544-2-git-send-email-jarod-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-07-28 14:42 ` Yishai Hadas
2016-07-27 19:17 ` [PATCH libmlx5 2/6] fix coverity buffer overrun warning Jarod Wilson
[not found] ` <1469647047-7544-3-git-send-email-jarod-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-07-28 14:46 ` Yishai Hadas
[not found] ` <9ee81879-93c4-97ee-eebf-3300533e4efe-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2016-07-28 16:37 ` Jarod Wilson
[not found] ` <20160728163714.GP36313-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-07-28 20:12 ` Jarod Wilson
2016-07-27 19:17 ` [PATCH libmlx5 3/6] fix buffer overrun copying inline header Jarod Wilson
[not found] ` <1469647047-7544-4-git-send-email-jarod-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-07-27 21:26 ` Jarod Wilson
[not found] ` <20160727212610.GJ36313-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-07-28 1:29 ` Jarod Wilson
2016-07-27 19:17 ` [PATCH libmlx5 4/6] fix check of mlx5_store_uidx return Jarod Wilson
[not found] ` <1469647047-7544-5-git-send-email-jarod-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-07-28 15:04 ` Yishai Hadas
2016-07-27 19:17 ` [PATCH libmlx5 5/6] fix alloc of mlx5_resource table Jarod Wilson
[not found] ` <1469647047-7544-6-git-send-email-jarod-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-07-28 15:25 ` Yishai Hadas
2016-07-27 19:17 ` [PATCH libmlx5 6/6] fix undefined uuar_index value assignment Jarod Wilson
[not found] ` <1469647047-7544-7-git-send-email-jarod-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-07-27 21:27 ` Jarod Wilson
2016-07-28 1:31 ` Jarod Wilson [this message]
[not found] ` <1469669515-23720-1-git-send-email-jarod-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-07-28 15:53 ` [PATCH v2 " Yishai Hadas
[not found] ` <828fc991-56e5-91e4-72e1-f10ca7c05aef-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2016-07-28 16:40 ` Jarod Wilson
2016-07-28 1:32 ` [PATCH libmlx5 7/6] combine inline_hdr and inline_hdr_start Jarod Wilson
[not found] ` <1469669554-23782-1-git-send-email-jarod-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-07-28 14:27 ` Jarod Wilson
[not found] ` <20160728142717.GO36313-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-07-28 16:39 ` Yishai Hadas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1469669515-23720-1-git-send-email-jarod@redhat.com \
--to=jarod-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).