[PATCH v2 0/6] nvme: fix transport request and queue error handling

From: shao.mingyin

Date: Fri Nov 13 2026 - 13:46:58 EST


The six patches fix independent error paths in the NVMe transports.

Patch 1 releases the target request in nvme-loop when SG setup fails.
nvmet_req_init() has already taken the queue, namespace and reservation
references, and blk-mq retries the same request, so each failure leaked a
set of references.

Patch 2 makes the TCP target wait for in-capsule data only when the SGL
is really an offset data block descriptor. The old check looked only at
the descriptor length, so a transport SGL of the same length was treated
as in-capsule data; the same check is used when request initialization
fails.

Patch 3 requires the R2T offset to equal the number of bytes already
sent. A larger offset let the host advertise an offset past the data
that its next H2CData PDU carried.

Patch 4 frees the fcloop LS request when nvmet_fc_rcv_ls_req() fails
before taking ownership.

Patch 5 publishes an FC target queue only if its slot is still free. A
duplicate Create Connection replaced the old pointer and leaked the queue
and its controller reference.

Patch 6 rolls back the SQ binding and the controller reference taken by
nvmet_install_queue() when the CQ is already bound to another controller,
and destroys the CQ binding when the transport cannot install the queue.

The six patches are independent and can be applied in any order or as a
subset. All carry Fixes: and Cc: stable.

Changes in v2:
- Patch 2: split the inline-SGL helper into separate conditions, as
requested by Christoph Hellwig. No functional change; a compiled
comparison of the old and new helpers found no mismatches.
- Patches 1 and 3-6: code and commit messages unchanged; add Christoph
Hellwig's Reviewed-by tags. Existing runtime evidence remains v1 data.
Previous version: https://lore.kernel.org/all/20261110230304050fijuDcYKyYPS3lffioSeA@xxxxxxxxxx/

Codex assisted with the review changes, descriptions and validation
scripts. The updated code was function-tested and build-tested.

Shao Mingyin (6):
nvme-loop: release the target request when SG setup fails
nvmet-tcp: only wait for in-capsule data for inline SGLs
nvme-tcp: require the R2T offset to match the data sent
nvmet-fcloop: free the LS request when delivery fails
nvmet-fc: reject duplicate queue IDs on Create Connection
nvmet: roll back queue bindings on connection failure

drivers/nvme/host/tcp.c | 2 +-
drivers/nvme/target/fabrics-cmd.c | 3 +++
drivers/nvme/target/fc.c | 13 ++++++++++--
drivers/nvme/target/fcloop.c | 2 ++
drivers/nvme/target/loop.c | 1 +
drivers/nvme/target/tcp.c | 42 +++++++++++++++++++++++++++------------
6 files changed, 47 insertions(+), 16 deletions(-)

---
base-commit: ddfe51b0a0f5dc9e415cc2c8ad8db17532dd426b