public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizf@cn.fujitsu.com>
To: Jens Axboe <jens.axboe@oracle.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] block: fix memory leak in bio_clone()
Date: Mon, 09 Mar 2009 17:13:00 +0800	[thread overview]
Message-ID: <49B4DD9C.5030902@cn.fujitsu.com> (raw)

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 

             reply	other threads:[~2009-03-09  9:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-09  9:13 Li Zefan [this message]
2009-03-09  9:21 ` [PATCH] block: fix memory leak in bio_clone() 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49B4DD9C.5030902@cn.fujitsu.com \
    --to=lizf@cn.fujitsu.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox