Skip to content

Commit b222dd2

Browse files
shligitaxboe
authored andcommitted
block: call bio_uninit in bio_endio
bio_free isn't a good place to free cgroup info. There are a lot of cases bio is allocated in special way (for example, in stack) and never gets called by bio_put hence bio_free, we are leaking memory. This patch moves the free to bio endio, which should be called anyway. The bio_uninit call in bio_free is kept, in case the bio never gets called bio endio. This assumes ->bi_end_io() doesn't access cgroup info, which seems true in my audit. This along with Christoph's integrity patch should fix the memory leak issue. Cc: Christoph Hellwig <[email protected]> Signed-off-by: Shaohua Li <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 459bd0d commit b222dd2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

block/bio.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,6 +1833,8 @@ void bio_endio(struct bio *bio)
18331833
}
18341834

18351835
blk_throtl_bio_endio(bio);
1836+
/* release cgroup info */
1837+
bio_uninit(bio);
18361838
if (bio->bi_end_io)
18371839
bio->bi_end_io(bio);
18381840
}

0 commit comments

Comments
 (0)