[PATCH v2] nvme-fc: initialize result on transport failure
Andrew Stellman
bugs at stellman-greene.com
Mon Nov 30 05:07:34 PST 2026
From: Andrew Stellman <astellman at stellman-greene.com>
nvme_fc_fcpio_done() declares result without an initializer. When a
command is aborted, it jumps to done without setting result and passes
it to nvme_try_complete_req(). For a passthrough command, the ioctl
then copies that uninitialized value to user space along with the host
aborted status.
Initialize result to zero.
Found with Quality Playbook
(https://github.com/andrewstellman/quality-playbook).
Fixes: 27fa9bc54541 ("nvme: split nvme status from block req->errors")
Signed-off-by: Andrew Stellman <astellman at stellman-greene.com>
---
Christoph, here's a shorter commit log for this one too.
v1: https://lore.kernel.org/linux-nvme/20261129135253.80729-1-bugs@stellman-greene.com/
For testing I used NVMe/FC loopback (fcloop) in an arm64 QEMU guest with
CONFIG_INIT_STACK_NONE=y and KASAN, and had a non-root user with read
access to /dev/nvme0 send Identify Controller while fcloop dropped the
command. Before the patch, the ioctl came back with the host aborted
status and a nonzero result, and after it the result was 0. OpenAI Codex
handled most of the setup, and I can send the reproducer on request.
Quality Playbook, the open-source code review tool I maintain, found
this one with Claude Opus 5.5, and OpenAI GPT-6 (Codex) drafted the
fix. Same caveat as my other patch: I went through all of it, but this
codebase is new to me, so I leaned a lot on AI explanations.
Andrew
drivers/nvme/host/fc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 2cbd744ffd22a..978ec029ac950 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -1902,7 +1902,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)
struct nvme_completion *cqe = &op->rsp_iu.cqe;
struct nvme_command *sqe = &op->cmd_iu.sqe;
__le16 status = cpu_to_le16(NVME_SC_SUCCESS << 1);
- union nvme_result result;
+ union nvme_result result = {};
bool terminate_assoc = true;
int opstate;
--
2.53.0
More information about the Linux-nvme
mailing list