]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
block: memory allocations in bounce_clone_bio must not fail
authorChristoph Hellwig <hch@lst.de>
Wed, 24 Feb 2021 07:24:07 +0000 (08:24 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 24 Feb 2021 15:55:00 +0000 (08:55 -0700)
The caller can't cope with a failure from bounce_clone_bio, so
use __GFP_NOFAIL for the passthrough case.  bio_alloc_bioset already
won't fail due to the use of mempools.

And yes, we need to get rid of this bock layer bouncing code entirely
sooner or later..

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bounce.c

index 417faaac36b691b6f7f9205a72cdecf27335882a..87983a35079c22b821e7aa21bf2a1a3b5a75164b 100644 (file)
@@ -242,12 +242,11 @@ static struct bio *bounce_clone_bio(struct bio *bio_src)
         *    __bio_clone_fast() anyways.
         */
        if (bio_is_passthrough(bio_src))
-               bio = bio_kmalloc(GFP_NOIO, bio_segments(bio_src));
+               bio = bio_kmalloc(GFP_NOIO | __GFP_NOFAIL,
+                                 bio_segments(bio_src));
        else
                bio = bio_alloc_bioset(GFP_NOIO, bio_segments(bio_src),
                                       &bounce_bio_set);
-       if (!bio)
-               return NULL;
        bio->bi_bdev            = bio_src->bi_bdev;
        if (bio_flagged(bio_src, BIO_REMAPPED))
                bio_set_flag(bio, BIO_REMAPPED);