* [PATCH] nvmet: fix memory leak of bio integrity
@ 2025-06-25 11:45 Dmitry Bogdanov
2025-06-30 6:36 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Bogdanov @ 2025-06-25 11:45 UTC (permalink / raw)
To: Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni, linux-nvme,
linux-kernel
Cc: linux, Dmitry Bogdanov, stable
If nvmet receives commands with metadata there is a continuous memory leak
of kmalloc-128 slab or more precisely bio->bi_integrity.
Since that [1] patch series the integrity is not get free at bio_end_io
for submitter owned integrity. It has to free explicitly.
After commit bf4c89fc8797 ("block: don't call bio_uninit from bio_endio")
each user of bio_init has to use bio_uninit as well. Otherwise the bio
integrity is not getting free. Nvmet uses bio_init for inline bios.
Uninit the inline bio to complete deallocation of integrity in bio.
[1] https://lore.kernel.org/all/20240702151047.1746127-1-hch@lst.de/
Cc: stable@vger.kernel.org # 6.11
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
---
drivers/nvme/target/nvmet.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index df69a9dee71c..51df72f5e89b 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -867,6 +867,8 @@ static inline void nvmet_req_bio_put(struct nvmet_req *req, struct bio *bio)
{
if (bio != &req->b.inline_bio)
bio_put(bio);
+ else
+ bio_uninit(bio);
}
#ifdef CONFIG_NVME_TARGET_TCP_TLS
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] nvmet: fix memory leak of bio integrity
2025-06-25 11:45 [PATCH] nvmet: fix memory leak of bio integrity Dmitry Bogdanov
@ 2025-06-30 6:36 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2025-06-30 6:36 UTC (permalink / raw)
To: Dmitry Bogdanov
Cc: Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni, linux-nvme,
linux-kernel, linux, stable
Thanks, applied to nvme-6.16.
I fixed up the commit message to include a Fixes tag and drop the
mailing list reference.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-30 6:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-25 11:45 [PATCH] nvmet: fix memory leak of bio integrity Dmitry Bogdanov
2025-06-30 6:36 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).