Skip to content

Commit 746d489

Browse files
Mike Marciniszyngregkh
authored andcommitted
RDMA/qib,hfi1: Fix MR reference count leak on write with immediate
commit 1feb40067cf04ae48d65f728d62ca255c9449178 upstream. 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: Tadeusz Struk <tadeusz.struk@intel.com> Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3ccf695 commit 746d489

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/infiniband/hw/qib/qib_rc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2088,8 +2088,10 @@ void qib_rc_rcv(struct qib_ctxtdata *rcd, struct qib_ib_header *hdr,
20882088
ret = qib_get_rwqe(qp, 1);
20892089
if (ret < 0)
20902090
goto nack_op_err;
2091-
if (!ret)
2091+
if (!ret) {
2092+
qib_put_ss(&qp->r_sge);
20922093
goto rnr_nak;
2094+
}
20932095
wc.ex.imm_data = ohdr->u.rc.imm_data;
20942096
hdrsize += 4;
20952097
wc.wc_flags = IB_WC_WITH_IMM;

0 commit comments

Comments
 (0)