diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index ec271ae4318faf6f15c8dd3402572168c2dfd308..fb9062b5022c7bb002700cdd003490f0dd5b67c4 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -173,10 +173,11 @@ static void * r10buf_pool_alloc(gfp_t gfp_flags, void *data) while (j--) for (i = 0; i < RESYNC_PAGES ; i++) safe_put_page(r10_bio->devs[j].bio->bi_io_vec[i].bv_page); - j = -1; + j = 0; out_free_bio: - while (++j < nalloc) { - bio_put(r10_bio->devs[j].bio); + for ( ; j < nalloc; j++) { + if (r10_bio->devs[j].bio) + bio_put(r10_bio->devs[j].bio); if (r10_bio->devs[j].repl_bio) bio_put(r10_bio->devs[j].repl_bio); }