Skip to content

Commit

Permalink
libhns: Fix uninitialized qp attr when flush cqe
Browse files Browse the repository at this point in the history
[ Upstream commit 23c2104 ]

When flushing cqe, the state of qp needs to be modified. The incoming qp
attr is not initialized, which may lead to undefined behavior.

Fixes: e1726e9 ("libhns: Support flush cqe for hip08 in user space")
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Signed-off-by: Nicolas Morey <nmorey@suse.com>
  • Loading branch information
Chengchang Tang authored and nmorey committed Jan 17, 2024
1 parent b1336c2 commit 83c7a1e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions providers/hns/hns_roce_u_hw_v2.c
Expand Up @@ -362,7 +362,7 @@ static int hns_roce_u_v2_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,

static int hns_roce_flush_cqe(struct hns_roce_qp *hr_qp, uint8_t status)
{
struct ibv_qp_attr attr;
struct ibv_qp_attr attr = {};
int attr_mask;

if (status != HNS_ROCE_V2_CQE_WR_FLUSH_ERR) {
Expand Down Expand Up @@ -1257,8 +1257,8 @@ int hns_roce_u_v2_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
struct hns_roce_qp *qp = to_hr_qp(ibvqp);
struct hns_roce_sge_info sge_info = {};
struct hns_roce_rc_sq_wqe *wqe;
struct ibv_qp_attr attr = {};
unsigned int wqe_idx, nreq;
struct ibv_qp_attr attr;
int ret;

ret = check_qp_send(ibvqp, ctx);
Expand Down Expand Up @@ -1412,7 +1412,7 @@ static int hns_roce_u_v2_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr,
struct hns_roce_context *ctx = to_hr_ctx(ibvqp->context);
struct hns_roce_qp *qp = to_hr_qp(ibvqp);
unsigned int wqe_idx, nreq, max_sge;
struct ibv_qp_attr attr;
struct ibv_qp_attr attr = {};
int ret;

ret = check_qp_recv(ibvqp, ctx);
Expand Down Expand Up @@ -2545,7 +2545,7 @@ static int wr_complete(struct ibv_qp_ex *ibv_qp)
struct hns_roce_context *ctx = to_hr_ctx(ibv_qp->qp_base.context);
struct hns_roce_qp *qp = to_hr_qp(&ibv_qp->qp_base);
unsigned int nreq = qp->sq.head - qp->rb_sq_head;
struct ibv_qp_attr attr;
struct ibv_qp_attr attr = {};
int err = qp->err;

if (err) {
Expand Down

0 comments on commit 83c7a1e

Please sign in to comment.