All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
To: Linux Btrfs <linux-btrfs@vger.kernel.org>
Cc: Chris Mason <chris.mason@oracle.com>
Subject: Re: [PATCH] Btrfs: fix memory leak in btrfs_ioctl_start_sync()
Date: Mon, 04 Apr 2011 10:52:13 +0900	[thread overview]
Message-ID: <4D99244D.5050704@jp.fujitsu.com> (raw)
In-Reply-To: <4D991A3B.9020805@jp.fujitsu.com>

Sorry. Ignore previous patch.
New patch is as follows.

Thanks,
Tsutomu

(2011/04/04 10:09), Tsutomu Itoh wrote:
> Free btrfs_trans_handle if btrfs_commit_transaction_async() fails.
> 
> Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
> ---
>  fs/btrfs/ioctl.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff -urNp linux-2.6.39-rc1/fs/btrfs/ioctl.c linux-2.6.39-rc1.new/fs/btrfs/ioctl.c
> --- linux-2.6.39-rc1/fs/btrfs/ioctl.c	2011-03-30 04:09:47.000000000 +0900
> +++ linux-2.6.39-rc1.new/fs/btrfs/ioctl.c	2011-04-04 09:52:17.000000000 +0900
> @@ -2436,8 +2436,10 @@ static noinline long btrfs_ioctl_start_s
>  		return PTR_ERR(trans);
>  	transid = trans->transid;
>  	ret = btrfs_commit_transaction_async(trans, root, 0);
> -	if (ret)
> +	if (ret) {
> +		kmem_cache_free(btrfs_trans_handle_cachep, trans);
>  		return ret;
> +	}
>  
>  	if (argp)
>  		if (copy_to_user(argp, &transid, sizeof(transid)))
> 


Call btrfs_end_transaction() if btrfs_commit_transaction_async() fails.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
---
 fs/btrfs/ioctl.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff -urNp linux-2.6.39-rc1/fs/btrfs/ioctl.c linux-2.6.39-rc1.new/fs/btrfs/ioctl.c
--- linux-2.6.39-rc1/fs/btrfs/ioctl.c	2011-03-30 04:09:47.000000000 +0900
+++ linux-2.6.39-rc1.new/fs/btrfs/ioctl.c	2011-04-04 10:46:45.000000000 +0900
@@ -2436,8 +2436,10 @@ static noinline long btrfs_ioctl_start_s
 		return PTR_ERR(trans);
 	transid = trans->transid;
 	ret = btrfs_commit_transaction_async(trans, root, 0);
-	if (ret)
+	if (ret) {
+		btrfs_end_transaction(trans, root);
 		return ret;
+	}
 
 	if (argp)
 		if (copy_to_user(argp, &transid, sizeof(transid)))



      reply	other threads:[~2011-04-04  1:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-04  1:09 [PATCH] Btrfs: fix memory leak in btrfs_ioctl_start_sync() Tsutomu Itoh
2011-04-04  1:52 ` Tsutomu Itoh [this message]

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=4D99244D.5050704@jp.fujitsu.com \
    --to=t-itoh@jp.fujitsu.com \
    --cc=chris.mason@oracle.com \
    --cc=linux-btrfs@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.