]> git.baikalelectronics.ru Git - kernel.git/commit
block: make bioset_exit() fully resilient against being called twice
authorJens Axboe <axboe@kernel.dk>
Sun, 29 May 2022 13:13:09 +0000 (07:13 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jun 2022 16:36:11 +0000 (18:36 +0200)
commit7a6f4877a200a825b679fae0b4cb3e5924c64ec6
tree1d45354cfa9cd3cc874ff671d266674ee4ed24fe
parenta1a427ee63f1f5cff7b250da72dc42384248d3d9
block: make bioset_exit() fully resilient against being called twice

[ Upstream commit aea9d92cfd7becc5c1b3398b882c956c26b59f51 ]

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: 94b92e98906a ("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>
block/bio.c