* [PATCH] nvmet: prevent double-free after metadata SGL allocation failure
@ 2026-10-22 6:29 Avi Weiss
2026-10-22 15:46 ` Keith Busch
0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread* Re: [PATCH] nvmet: prevent double-free after metadata SGL allocation failure
2026-10-22 6:29 [PATCH] nvmet: prevent double-free after metadata SGL allocation failure Avi Weiss
@ 2026-10-22 15:46 ` Keith Busch
0 siblings, 0 replies; 2+ messages in thread
From: Keith Busch @ 2026-10-22 15:46 UTC (permalink / raw)
To: Avi Weiss
Cc: Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni, linux-nvme,
linux-kernel
On Thu, Oct 22, 2026 at 09:29:23AM +0300, Avi Weiss wrote:
> 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.
Looks good, applied to nvme-7.4.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-22 15:46 UTC | newest]
Thread overview: 2+ messages (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
2026-10-22 15:46 ` Keith Busch
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®