linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: fix memory leak in start_transaction()
@ 2011-04-03 12:31 Yoshinori Sano
  2011-04-04  0:14 ` Tsutomu Itoh
  0 siblings, 1 reply; 3+ messages in thread
From: Yoshinori Sano @ 2011-04-03 12:31 UTC (permalink / raw)
  To: linux-btrfs; +Cc: chris.mason, Yoshinori Sano

Free btrfs_trans_handle when join_transaction() fails
in start_transaction()

Signed-off-by: Yoshinori Sano <yoshinori.sano@gmail.com>
---
 fs/btrfs/transaction.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index ce48eb5..d01cc24 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -197,6 +197,7 @@ again:
 
 	ret = join_transaction(root);
 	if (ret < 0) {
+		kmem_cache_free(btrfs_trans_handle_cachep, h);
 		if (type != TRANS_JOIN_NOLOCK)
 			mutex_unlock(&root->fs_info->trans_mutex);
 		return ERR_PTR(ret);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [PATCH] Btrfs: fix memory leak in start_transaction()
@ 2012-09-20  4:14 Miao Xie
  0 siblings, 0 replies; 3+ messages in thread
From: Miao Xie @ 2012-09-20  4:14 UTC (permalink / raw)
  To: Josef Bacik; +Cc: Linux Btrfs

This patch fixes memory leak of the transaction handle which happened
when starting transaction failed on a freezed fs.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
This patch is based on btrfs-next tree
---
 fs/btrfs/transaction.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index e766d37..9bf9f6f 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -351,8 +351,10 @@ again:
 	 */
 	if (type != TRANS_JOIN_NOLOCK &&
 	    !__sb_start_write(root->fs_info->sb, SB_FREEZE_FS, false)) {
-		if (type == TRANS_JOIN_FREEZE)
+		if (type == TRANS_JOIN_FREEZE) {
+			kmem_cache_free(btrfs_trans_handle_cachep, h);
 			return ERR_PTR(-EPERM);
+		}
 		sb_start_intwrite(root->fs_info->sb);
 	}
 
-- 
1.7.6.5

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

end of thread, other threads:[~2012-09-20  4:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-03 12:31 [PATCH] Btrfs: fix memory leak in start_transaction() Yoshinori Sano
2011-04-04  0:14 ` Tsutomu Itoh
  -- strict thread matches above, loose matches on Subject: below --
2012-09-20  4:14 Miao Xie

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).