cleanup:
        rbio_orig_end_io(rbio, BLK_STS_IOERR);
+
+       while ((bio = bio_list_pop(&bio_list)))
+               bio_put(bio);
 }
 
 /*
 
 cleanup:
        rbio_orig_end_io(rbio, BLK_STS_IOERR);
+
+       while ((bio = bio_list_pop(&bio_list)))
+               bio_put(bio);
+
        return -EIO;
 
 finish:
        if (rbio->operation == BTRFS_RBIO_READ_REBUILD ||
            rbio->operation == BTRFS_RBIO_REBUILD_MISSING)
                rbio_orig_end_io(rbio, BLK_STS_IOERR);
+
+       while ((bio = bio_list_pop(&bio_list)))
+               bio_put(bio);
+
        return -EIO;
 }
 
 
 cleanup:
        rbio_orig_end_io(rbio, BLK_STS_IOERR);
+
+       while ((bio = bio_list_pop(&bio_list)))
+               bio_put(bio);
 }
 
 static inline int is_data_stripe(struct btrfs_raid_bio *rbio, int stripe)
        int stripe;
        struct bio *bio;
 
+       bio_list_init(&bio_list);
+
        ret = alloc_rbio_essential_pages(rbio);
        if (ret)
                goto cleanup;
 
-       bio_list_init(&bio_list);
-
        atomic_set(&rbio->error, 0);
        /*
         * build a list of bios to read all the missing parts of this
 
 cleanup:
        rbio_orig_end_io(rbio, BLK_STS_IOERR);
+
+       while ((bio = bio_list_pop(&bio_list)))
+               bio_put(bio);
+
        return;
 
 finish: