Skip to content

Commit a647a52

Browse files
Ming Leiaxboe
authored andcommitted
block: don't call rq_qos_ops->done_bio if the bio isn't tracked
rq_qos framework is only applied on request based driver, so: 1) rq_qos_done_bio() needn't to be called for bio based driver 2) rq_qos_done_bio() needn't to be called for bio which isn't tracked, such as bios ended from error handling code. Especially in bio_endio(): 1) request queue is referred via bio->bi_bdev->bd_disk->queue, which may be gone since request queue refcount may not be held in above two cases 2) q->rq_qos may be freed in blk_cleanup_queue() when calling into __rq_qos_done_bio() Fix the potential kernel panic by not calling rq_qos_ops->done_bio if the bio isn't tracked. This way is safe because both ioc_rqos_done_bio() and blkcg_iolatency_done_bio() are nop if the bio isn't tracked. Reported-by: Yu Kuai <[email protected]> Cc: [email protected] Signed-off-by: Ming Lei <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Acked-by: Tejun Heo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 5cad875 commit a647a52

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

block/bio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ void bio_endio(struct bio *bio)
14661466
if (!bio_integrity_endio(bio))
14671467
return;
14681468

1469-
if (bio->bi_bdev)
1469+
if (bio->bi_bdev && bio_flagged(bio, BIO_TRACKED))
14701470
rq_qos_done_bio(bio->bi_bdev->bd_disk->queue, bio);
14711471

14721472
if (bio->bi_bdev && bio_flagged(bio, BIO_TRACE_COMPLETION)) {

0 commit comments

Comments
 (0)