[Btrfs-devel] extent_io.c: bio_add_page() error check for bio ptr

Peter Teoh htmldeveloper at gmail.com
Sat Mar 15 21:36:48 PDT 2008


bio_add_page() requires non-NULL bio ptr for dereferencing.

Signed-off-by: Peter Teoh <htmldeveloper at gmail.com>

--- extent_io.c.orig1   2008-03-16 12:43:59.000000000 +0800
+++ extent_io.c 2008-03-16 12:45:03.000000000 +0800
@@ -1729,6 +1729,7 @@ static int submit_extent_page(int rw, st

        if (bio_ret && *bio_ret) {
                bio = *bio_ret;
+               BUG_ON(!bio);
                if (bio->bi_sector + (bio->bi_size >> 9) != sector ||
                    bio_add_page(bio, page, size, offset) < size) {
                        ret = submit_one_bio(rw, bio);
@@ -1741,6 +1742,7 @@ static int submit_extent_page(int rw, st
        bio = extent_bio_alloc(bdev, sector, nr, GFP_NOFS | __GFP_HIGH);
        if (!bio) {
                printk("failed to allocate bio nr %d\n", nr);
+               BUG_ON(!bio);
        }




-- 
Regards,
Peter Teoh



More information about the Btrfs-devel mailing list