Skip to content

Commit

Permalink
block: make bioset_exit() fully resilient against being called twice
Browse files Browse the repository at this point in the history
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: be4d234 ("bio: add allocation cache abstraction")
Link: https://lore.kernel.org/linux-block/[email protected]/
Reported-by: Matthew Wilcox <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed May 29, 2022
1 parent ebd076b commit 605f741
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions block/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 605f741

Please sign in to comment.