aboutsummaryrefslogtreecommitdiff
path: root/drivers/md/raid10.c
diff options
context:
space:
mode:
authormajianpeng <majianpeng@gmail.com>2012-05-22 13:55:03 +1000
committerNeilBrown <neilb@suse.de>2012-05-22 13:55:03 +1000
commit5fdd2cf8265c6de0f190dea80cc4c50da8f31293 (patch)
treeddb9bb1da6654d9d9de86c916fceed8280be95fe /drivers/md/raid10.c
parentda8840a747c0dbf49506ec906757a6b87b9741e9 (diff)
md/raid10: Fix memleak in r10buf_pool_alloc
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>
Diffstat (limited to 'drivers/md/raid10.c')
-rw-r--r--drivers/md/raid10.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index ec271ae4318..fb9062b5022 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -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);
}