提交 9d8e7d0d 编写于 作者: B Bart Van Assche 提交者: Doug Ledford

IB/srp: Fix a memory descriptor leak in an error path

If an error occurs after srp_fr_pool_get() succeeded and before the
descriptor is stored in srp_map_state (*state->fr.next++ = desc)
then srp_unmap_data() won't free the newly allocated memory
descriptor. Hence free the descriptor explicitly.

Fixes: f7f7aab1 ("IB/srp: Convert to new registration API")
Signed-off-by: NBart Van Assche <bart.vanassche@sandisk.com>
Tested-by: NLaurence Oberman <loberman@redhat.com>
Cc: Sagi Grimberg <sai@grimberg.me>
Cc: Christoph Hellwig <hch@lst.de>
Cc: <stable@vger.kernel.org> # v4.4+
Signed-off-by: NDoug Ledford <dledford@redhat.com>
上级 cf1acab7
......@@ -1330,8 +1330,13 @@ static int srp_map_finish_fr(struct srp_map_state *state,
ib_update_fast_reg_key(desc->mr, rkey);
n = ib_map_mr_sg(desc->mr, state->sg, sg_nents, 0, dev->mr_page_size);
if (unlikely(n < 0))
if (unlikely(n < 0)) {
srp_fr_pool_put(ch->fr_pool, &desc, 1);
pr_debug("%s: ib_map_mr_sg(%d) returned %d.\n",
dev_name(&req->scmnd->device->sdev_gendev), sg_nents,
n);
return n;
}
req->reg_cqe.done = srp_reg_mr_err_done;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册