Skip to content

Commit 67807fb

Browse files
Vasily Gorbikaxboe
authored andcommitted
block: fix bio_alloc_bioset slowpath GFP handling
bio_alloc_bioset() first strips __GFP_DIRECT_RECLAIM from the optimistic fast allocation attempt with try_alloc_gfp(). If that fast path fails, the slowpath checks saved_gfp to decide whether blocking allocation is allowed, but then still calls mempool_alloc() with the stripped gfp mask. That can lead to a NULL bio pointer being passed into bio_init(). Fix the slowpath by using saved_gfp for the bio and bvec mempool allocations. Fixes: b520c4e ("block: split bio_alloc_bioset more clearly into a fast and slowpath") Reported-by: [email protected] Signed-off-by: Vasily Gorbik <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 24d4c90 commit 67807fb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

block/bio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,11 @@ struct bio *bio_alloc_bioset(struct block_device *bdev, unsigned short nr_vecs,
581581
*/
582582
opf &= ~REQ_ALLOC_CACHE;
583583

584-
p = mempool_alloc(&bs->bio_pool, gfp);
584+
p = mempool_alloc(&bs->bio_pool, saved_gfp);
585585
bio = p + bs->front_pad;
586586
if (nr_vecs > BIO_INLINE_VECS) {
587587
nr_vecs = BIO_MAX_VECS;
588-
bvecs = mempool_alloc(&bs->bvec_pool, gfp);
588+
bvecs = mempool_alloc(&bs->bvec_pool, saved_gfp);
589589
}
590590
}
591591

0 commit comments

Comments
 (0)