From: Shao Mingyin fcloop_h2t_ls_req() allocates a fcloop_lsreq from lsreq_cache and hands it to nvmet_fc_rcv_ls_req(). That function only takes ownership on success and returns an error without invoking any completion callback when the target port is shutting down, the LS payload is too large, or the target has no free LS request slot. The error is returned as-is, so the fcloop_lsreq is leaked; every failed LS during a target port teardown or an LS slot exhaustion loses one slab object. The target-to-host direction already frees the request when nvme_fc_rcv_ls_req() fails. Do the same here. Fixes: 772042dd38ee ("nvmet-fcloop: allocate/free fcloop_lsreq directly") Cc: stable@vger.kernel.org Reviewed-by: Christoph Hellwig Signed-off-by: Shao Mingyin --- Changes in v2: - Code and commit message unchanged; add Christoph Hellwig's Reviewed-by tag. Previous version: https://lore.kernel.org/all/20261110230313720JCGXeTg2zOideed82vWy9@zte.com.cn/ Tested on 7.3.0-next-20261030 (QEMU/TCG guest) with the fcloop loopback transport (nvme-fc host + nvmet-fc/fcloop target); no real FC HBA is required. The -ESHUTDOWN error path is otherwise only hit in a sub-instruction teardown race, so it is exercised with two TEST-ONLY changes (not part of this patch): a debugfs knob that makes nvmet_fc_rcv_ls_req() return -ESHUTDOWN, and SLAB_NO_MERGE on lsreq_cache so the 72-byte fcloop_lsreq does not merge into a kmalloc cache. A stock host sends 120 Create Association LS with ctrl_loss_tmo=0 (each failure deletes the controller); the cache is shrunk afterwards, which only reclaims empty slabs: unpatched patched lsreq_cache objects 0 -> 120 lsreq_cache objects stays 0 slabs 0 -> 4 slabs stay 0 drivers/nvme/target/fcloop.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c index b63af3b643a648dc6878ab5afaa711b6294bf5c3..a9cde536c33ba11ced49bf74314aa5eed714df48 100644 --- a/drivers/nvme/target/fcloop.c +++ b/drivers/nvme/target/fcloop.c @@ -379,6 +379,8 @@ fcloop_h2t_ls_req(struct nvme_fc_local_port *localport, ret = nvmet_fc_rcv_ls_req(rport->targetport, rport, &tls_req->ls_rsp, lsreq->rqstaddr, lsreq->rqstlen); + if (ret) + kmem_cache_free(lsreq_cache, tls_req); return ret; } -- 2.27.0