diff options
author | Jens Axboe <axboe@kernel.dk> | 2022-05-29 07:13:09 -0600 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-06-14 18:36:11 +0200 |
commit | 4a45a7dcc55e358d7757e31bdf2d53891343737b (patch) | |
tree | 1d45354cfa9cd3cc874ff671d266674ee4ed24fe /block/bio.c | |
parent | 06cb7e134f8f4a11b66f1dbeb5f237412a0aeedc (diff) |
block: make bioset_exit() fully resilient against being called twice
[ Upstream commit 605f7415ecfb426610195dd6c7577b30592b3369 ]
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 <willy@infradead.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'block/bio.c')
-rw-r--r-- | block/bio.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/block/bio.c b/block/bio.c index 9b28381412d2..8381c6690dd6 100644 --- a/block/bio.c +++ b/block/bio.c @@ -665,6 +665,7 @@ static void bio_alloc_cache_destroy(struct bio_set *bs) bio_alloc_cache_prune(cache, -1U); } free_percpu(bs->cache); + bs->cache = NULL; } /** |