Skip to content

Commit

Permalink
libhns: Fix reference to uninitialized cq pointer
Browse files Browse the repository at this point in the history
For QPs which do not have an SQ, such as XRC TGT,the send_cq
pointer will not be initailized. Since the supported max_gs
will be 0 in this case, check it and return before referencing
the send_cq pointer.

Fixes: cbdf5e3 ("libhns: Reimplement verbs of post_send and post_recv for hip08 RoCE")
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
  • Loading branch information
Chengchang Tang authored and Junxian Huang committed Nov 8, 2024
1 parent c411991 commit c0fb9b5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions providers/hns/hns_roce_u_hw_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1288,15 +1288,15 @@ int hns_roce_u_v2_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
sge_info.start_idx = qp->next_sge; /* start index of extend sge */

for (nreq = 0; wr; ++nreq, wr = wr->next) {
if (hns_roce_v2_wq_overflow(&qp->sq, nreq,
to_hr_cq(qp->verbs_qp.qp.send_cq))) {
ret = ENOMEM;
if (wr->num_sge > (int)qp->sq.max_gs) {
ret = qp->sq.max_gs > 0 ? EINVAL : EOPNOTSUPP;
*bad_wr = wr;
goto out;
}

if (wr->num_sge > qp->sq.max_gs) {
ret = EINVAL;
if (hns_roce_v2_wq_overflow(&qp->sq, nreq,
to_hr_cq(qp->verbs_qp.qp.send_cq))) {
ret = ENOMEM;
*bad_wr = wr;
goto out;
}
Expand Down

0 comments on commit c0fb9b5

Please # to comment.