linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] md/raid10:Memleak fix if allocate rep1_bio failed in  function want_replacement().
@ 2012-04-16 11:24 majianpeng
  2012-04-17  3:09 ` NeilBrown
  0 siblings, 1 reply; 2+ messages in thread
From: majianpeng @ 2012-04-16 11:24 UTC (permalink / raw)
  To: Neil Brown; +Cc: linux-raid

From cb391c87d24a32b211d9f0a9df942987bf8e0ac4 Mon Sep 17 00:00:00 2001
From: majianpeng <majianpeng@gmail.com>
Date: Mon, 16 Apr 2012 19:19:53 +0800
Subject: [PATCH] md/raid10:Memleak fix if allocate rep1_bio failed in
 function want_replacement().
 Reported by kmemleak.

Signed-off-by: majianpeng <majianpeng@gmail.com>
---
 drivers/md/raid10.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index c8dbb84..19e9af1 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -165,10 +165,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);
 	}
-- 
1.7.5.4

 				
--------------
majianpeng
2012-04-16


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-17  3:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-16 11:24 [PATCH] md/raid10:Memleak fix if allocate rep1_bio failed in function want_replacement() majianpeng
2012-04-17  3:09 ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).