Skip to content

Commit

Permalink
md/raid10: Fix memleak in r10buf_pool_alloc
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
majianpeng authored and NeilBrown committed May 22, 2012
1 parent da8840a commit 5fdd2cf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/md/raid10.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5fdd2cf

Please sign in to comment.