]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
md/raid10: Fix memleak in r10buf_pool_alloc
authormajianpeng <majianpeng@gmail.com>
Tue, 24 Apr 2012 00:57:52 +0000 (10:57 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 24 Apr 2012 00:57:52 +0000 (10:57 +1000)
If the allocation of rep1_bio fails, we currently don't free the 'bio'
of the same dev.

Reported by kmemleak.

Signed-off-by: majianpeng <majianpeng@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/raid10.c

index 4ab0fd31df29179eae16cec0309b439f26d72e02..728fcab972e62d091212dc1a070f014303f4c9b7 100644 (file)
@@ -173,10 +173,11 @@ out_free_pages:
        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);
        }