提交 1feb4006 编写于 作者: M Mike Marciniszyn 提交者: Doug Ledford

RDMA/qib,hfi1: Fix MR reference count leak on write with immediate

The handling of IB_RDMA_WRITE_ONLY_WITH_IMMEDIATE will leak a memory
reference when a buffer cannot be allocated for returning the immediate
data.

The issue is that the rkey validation has already occurred and the RNR
nak fails to release the reference that was fruitlessly gotten.  The
the peer will send the identical single packet request when its RNR
timer pops.

The fix is to release the held reference prior to the rnr nak exit.
This is the only sequence the requires both rkey validation and the
buffer allocation on the same packet.

Cc: Stable <stable@vger.kernel.org> # 4.7+
Tested-by: NTadeusz Struk <tadeusz.struk@intel.com>
Reviewed-by: NDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: NMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: NDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: NDoug Ledford <dledford@redhat.com>
上级 b3e6b4bd
...@@ -2159,8 +2159,11 @@ void hfi1_rc_rcv(struct hfi1_packet *packet) ...@@ -2159,8 +2159,11 @@ void hfi1_rc_rcv(struct hfi1_packet *packet)
ret = hfi1_rvt_get_rwqe(qp, 1); ret = hfi1_rvt_get_rwqe(qp, 1);
if (ret < 0) if (ret < 0)
goto nack_op_err; goto nack_op_err;
if (!ret) if (!ret) {
/* peer will send again */
rvt_put_ss(&qp->r_sge);
goto rnr_nak; goto rnr_nak;
}
wc.ex.imm_data = ohdr->u.rc.imm_data; wc.ex.imm_data = ohdr->u.rc.imm_data;
wc.wc_flags = IB_WC_WITH_IMM; wc.wc_flags = IB_WC_WITH_IMM;
goto send_last; goto send_last;
......
...@@ -1956,8 +1956,10 @@ void qib_rc_rcv(struct qib_ctxtdata *rcd, struct ib_header *hdr, ...@@ -1956,8 +1956,10 @@ void qib_rc_rcv(struct qib_ctxtdata *rcd, struct ib_header *hdr,
ret = qib_get_rwqe(qp, 1); ret = qib_get_rwqe(qp, 1);
if (ret < 0) if (ret < 0)
goto nack_op_err; goto nack_op_err;
if (!ret) if (!ret) {
rvt_put_ss(&qp->r_sge);
goto rnr_nak; goto rnr_nak;
}
wc.ex.imm_data = ohdr->u.rc.imm_data; wc.ex.imm_data = ohdr->u.rc.imm_data;
hdrsize += 4; hdrsize += 4;
wc.wc_flags = IB_WC_WITH_IMM; wc.wc_flags = IB_WC_WITH_IMM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册