]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nvmet: fix memory leak of bio integrity
authorDmitry Bogdanov <d.bogdanov@yadro.com>
Wed, 25 Jun 2025 11:45:33 +0000 (14:45 +0300)
committerChristoph Hellwig <hch@lst.de>
Mon, 30 Jun 2025 06:32:16 +0000 (08:32 +0200)
If nvmet receives commands with metadata there is a continuous memory
leak of kmalloc-128 slab or more precisely bio->bi_integrity.

Since 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.

Fixes: bf4c89fc8797 ("block: don't call bio_uninit from bio_endio")
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/nvmet.h

index df69a9dee71cb31c1f61c415de19a8ccb0cabd68..51df72f5e89b72a271ea54124a946fdce94fbc89 100644 (file)
@@ -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