* [PATCH] nvmet: prevent double-free after metadata SGL allocation failure
@ 2026-10-22 6:29 Avi Weiss
0 siblings, 0 replies; only message in thread
From: Avi Weiss @ 2026-10-22 6:29 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Sagi Grimberg, Chaitanya Kulkarni, linux-nvme, linux-kernel, Avi Weiss
If metadata SGL allocation fails, nvmet_req_alloc_sgls() frees
req->sg without clearing it. The RDMA error completion path later
frees the same scatterlist again.
Use nvmet_req_free_sgls() instead so that the scatterlist pointers
and counts are cleared before response cleanup.
Fixes: c6e3f13398123 ("nvmet: add metadata support for block devices")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
drivers/nvme/target/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 07a74c2e1f58..8032924e657f 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -1359,7 +1359,7 @@ int nvmet_req_alloc_sgls(struct nvmet_req *req)
return 0;
out_free:
- sgl_free(req->sg);
+ nvmet_req_free_sgls(req);
out:
return -ENOMEM;
}
base-commit: a804c5742bff224d4cb4d25dd383554d598be32b
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-22 6:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-22 6:29 [PATCH] nvmet: prevent double-free after metadata SGL allocation failure Avi Weiss
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®