public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: fix memory leak in bio_clone()
@ 2009-03-09  9:13 Li Zefan
  2009-03-09  9:21 ` Li Zefan
  2009-03-09  9:24 ` Jens Axboe
  0 siblings, 2 replies; 11+ messages in thread
From: Li Zefan @ 2009-03-09  9:13 UTC (permalink / raw)
  To: Jens Axboe; +Cc: LKML

If bio_integrity_clone() fails, bio_clone() returns NULL without freeing
the newly allocated bio.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 fs/bio.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/bio.c b/fs/bio.c
index 124b95c..896330e 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -465,8 +465,10 @@ struct bio *bio_clone(struct bio *bio, gfp_t gfp_mask)
 
 		ret = bio_integrity_clone(b, bio, fs_bio_set);
 
-		if (ret < 0)
+		if (ret < 0) {
+			bio_put(bio);
 			return NULL;
+		}
 	}
 
 	return b;
-- 1.5.4.rc3 

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

end of thread, other threads:[~2009-03-10  7:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-09  9:13 [PATCH] block: fix memory leak in bio_clone() Li Zefan
2009-03-09  9:21 ` Li Zefan
2009-03-09  9:24 ` Jens Axboe
2009-03-09  9:34   ` Li Zefan
2009-03-09  9:38     ` Jens Axboe
2009-03-09  9:51       ` Li Zefan
2009-03-09  9:54         ` Jens Axboe
2009-03-09 16:10   ` Martin K. Petersen
2009-03-09 19:21     ` Jens Axboe
2009-03-10  3:42       ` Martin K. Petersen
2009-03-10  7:29         ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox