diff options
authorMike Marciniszyn <>2017-05-12 09:02:00 -0700
committerGreg Kroah-Hartman <>2017-06-12 17:25:52 +0200
commit9ec773b3dd2dc13a53c65b40c95ab25b0abd5409 (patch)
parentbf952b9330ee17d62e68eb32135ee8a4eb3193d2 (diff)
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 <> # 4.7+ Tested-by: Tadeusz Struk <> Reviewed-by: Dennis Dalessandro <> Signed-off-by: Mike Marciniszyn <> Signed-off-by: Dennis Dalessandro <> Signed-off-by: Doug Ledford <> Signed-off-by: Greg Kroah-Hartman <>
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/qib/qib_rc.c b/drivers/infiniband/hw/qib/qib_rc.c
index e6b7556d5221..cbc4216091c9 100644
--- a/drivers/infiniband/hw/qib/qib_rc.c
+++ b/drivers/infiniband/hw/qib/qib_rc.c
@@ -2088,8 +2088,10 @@ send_last:
ret = qib_get_rwqe(qp, 1);
if (ret < 0)
goto nack_op_err;
- if (!ret)
+ if (!ret) {
+ qib_put_ss(&qp->r_sge);
goto rnr_nak;
+ }
wc.ex.imm_data = ohdr->u.rc.imm_data;
hdrsize += 4;
wc.wc_flags = IB_WC_WITH_IMM;