Skip to content

Commit 6afa2c0

Browse files
Junxian Huangrleon
authored andcommitted
RDMA/hns: Check atomic wr length
8 bytes is the only supported length of atomic. Add this check in set_rc_wqe(). Besides, stop processing WQEs and return from set_rc_wqe() if there is any error. Fixes: 384f881 ("RDMA/hns: Add atomic support") Signed-off-by: Junxian Huang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent b851268 commit 6afa2c0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

drivers/infiniband/hw/hns/hns_roce_device.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
/* Configure to HW for PAGE_SIZE larger than 4KB */
9292
#define PG_SHIFT_OFFSET (PAGE_SHIFT - 12)
9393

94+
#define ATOMIC_WR_LEN 8
95+
9496
#define HNS_ROCE_IDX_QUE_ENTRY_SZ 4
9597
#define SRQ_DB_REG 0x230
9698

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,11 +591,16 @@ static inline int set_rc_wqe(struct hns_roce_qp *qp,
591591
(wr->send_flags & IB_SEND_SIGNALED) ? 1 : 0);
592592

593593
if (wr->opcode == IB_WR_ATOMIC_CMP_AND_SWP ||
594-
wr->opcode == IB_WR_ATOMIC_FETCH_AND_ADD)
594+
wr->opcode == IB_WR_ATOMIC_FETCH_AND_ADD) {
595+
if (msg_len != ATOMIC_WR_LEN)
596+
return -EINVAL;
595597
set_atomic_seg(wr, rc_sq_wqe, valid_num_sge);
596-
else if (wr->opcode != IB_WR_REG_MR)
598+
} else if (wr->opcode != IB_WR_REG_MR) {
597599
ret = set_rwqe_data_seg(&qp->ibqp, wr, rc_sq_wqe,
598600
&curr_idx, valid_num_sge);
601+
if (ret)
602+
return ret;
603+
}
599604

600605
/*
601606
* The pipeline can sequentially post all valid WQEs into WQ buffer,

0 commit comments

Comments
 (0)