* this branch is our 'one mirror IO has finished' event handler:
                 */
                r1_bio->bios[mirror] = NULL;
-               bio_put(bio);
                if (!uptodate) {
                        md_error(r1_bio->mddev, conf->mirrors[mirror].rdev);
                        /* an I/O failed, we can't clear the bitmap */
                }
                if (test_bit(R1BIO_BehindIO, &r1_bio->state)) {
                        /* free extra copy of the data pages */
-/* FIXME bio has been freed!!! */
                        int i = bio->bi_vcnt;
                        while (i--)
                                __free_page(bio->bi_io_vec[i].bv_page);
                raid_end_bio_io(r1_bio);
        }
 
+       if (r1_bio->bios[mirror]==NULL)
+               bio_put(bio);
+
        rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev);
        return 0;
 }