From: Jens Axboe Date: Sun, 29 May 2022 13:13:09 +0000 (-0600) Subject: block: make bioset_exit() fully resilient against being called twice X-Git-Tag: howlett/maple/20220722_2~359^2~4 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=605f7415ecfb426610195dd6c7577b30592b3369;p=users%2Fjedix%2Flinux-maple.git block: make bioset_exit() fully resilient against being called twice Most of bioset_exit() is fine being called twice, as it clears the various allocations etc when they are freed. The exception is bio_alloc_cache_destroy(), which does not clear ->cache when it has freed it. This isn't necessarily a bug, but can be if buggy users does call the exit path more then once, or with just a memset() bioset which has never been initialized. dm appears to be one such user. Fixes: be4d234d7aeb ("bio: add allocation cache abstraction") Link: https://lore.kernel.org/linux-block/YpK7m+14A+pZKs5k@casper.infradead.org/ Reported-by: Matthew Wilcox Signed-off-by: Jens Axboe --- diff --git a/block/bio.c b/block/bio.c index 8a1b3d650a7f7..f92d0223247b7 100644 --- a/block/bio.c +++ b/block/bio.c @@ -722,6 +722,7 @@ static void bio_alloc_cache_destroy(struct bio_set *bs) bio_alloc_cache_prune(cache, -1U); } free_percpu(bs->cache); + bs->cache = NULL; } /**