]> git.baikalelectronics.ru Git - kernel.git/commit
bcache: fix crashes stopping bcache device before read miss done
authorGuoju Fang <fangguoju@gmail.com>
Wed, 24 Apr 2019 16:48:26 +0000 (00:48 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 24 Apr 2019 16:56:27 +0000 (10:56 -0600)
commit6693d5592363aab795ae102d69ddef03e7a4c05c
tree1d06009c00ed9357f1975120991ae6ac08f7f2c5
parent11a561e2b38b095645dc37e14a606f5712b7fef6
bcache: fix crashes stopping bcache device before read miss done

The bio from upper layer is considered completed when bio_complete()
returns. In most scenarios bio_complete() is called in search_free(),
but when read miss happens, the bio_compete() is called when backing
device reading completed, while the struct search is still in use until
cache inserting finished.

If someone stops the bcache device just then, the device may be closed
and released, but after cache inserting finished the struct search will
access a freed struct cached_dev.

This patch add the reference of bcache device before bio_complete() when
read miss happens, and put it after the search is not used.

Signed-off-by: Guoju Fang <fangguoju@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/request.c