FAILED: patch "[PATCH] IB/srp: Fix a memory descriptor leak in an error path" failed to apply to 4.6-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 4.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
Quoted 1 line
From
9d8e7d0dacf09ddac7e617d17dbeec6af56e81e8Mon Sep 17 00:00:00 2001
From: Bart Van Assche <[email protected]>
Date: Thu, 12 May 2016 10:48:13 -0700
Subject: [PATCH] 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.
drivers/infiniband/ulp/srp/ib_srp.c +6 -1
@@ -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;