diff mbox

Btrfs: fix memory leak in start_transaction()

Message ID 1301833888-31238-1-git-send-email-yoshinori.sano@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yoshinori Sano April 3, 2011, 12:31 p.m. UTC
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(-)

Comments

Tsutomu Itoh April 4, 2011, 12:14 a.m. UTC | #1
(2011/04/03 21:31), Yoshinori Sano wrote:
> Free btrfs_trans_handle when join_transaction() fails
> in start_transaction()

Woops! It's my mistake in http://marc.info/?l=linux-btrfs&m=130086817629289&w=2.
Thanks for the point.

---
Tsutomu

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

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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