linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: fix bh leak on error paths in ext4_rename() and ext4_cross_rename()
@ 2015-03-03 11:17 Konstantin Khlebnikov
  2015-03-04 15:03 ` Jan Kara
  2015-04-02 20:36 ` Theodore Ts'o
  0 siblings, 2 replies; 3+ messages in thread
From: Konstantin Khlebnikov @ 2015-03-03 11:17 UTC (permalink / raw)
  To: Andreas Dilger, linux-ext4, Theodore Ts'o; +Cc: linux-kernel

Release references to buffer-heads if ext4_journal_start() fails.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Fixes: 5b61de757535 ("ext4: start handle at least possible moment when renaming files")
---
 fs/ext4/namei.c |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 28fe71a2904c..8110dd20ad3f 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -3264,12 +3264,18 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
 		   EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2);
 	if (!(flags & RENAME_WHITEOUT)) {
 		handle = ext4_journal_start(old.dir, EXT4_HT_DIR, credits);
-		if (IS_ERR(handle))
-			return PTR_ERR(handle);
+		if (IS_ERR(handle)) {
+			retval = PTR_ERR(handle);
+			handle = NULL;
+			goto end_rename;
+		}
 	} else {
 		whiteout = ext4_whiteout_for_rename(&old, credits, &handle);
-		if (IS_ERR(whiteout))
-			return PTR_ERR(whiteout);
+		if (IS_ERR(whiteout)) {
+			retval = PTR_ERR(whiteout);
+			whiteout = NULL;
+			goto end_rename;
+		}
 	}
 
 	if (IS_DIRSYNC(old.dir) || IS_DIRSYNC(new.dir))
@@ -3433,8 +3439,11 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
 	handle = ext4_journal_start(old.dir, EXT4_HT_DIR,
 		(2 * EXT4_DATA_TRANS_BLOCKS(old.dir->i_sb) +
 		 2 * EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2));
-	if (IS_ERR(handle))
-		return PTR_ERR(handle);
+	if (IS_ERR(handle)) {
+		retval = PTR_ERR(handle);
+		handle = NULL;
+		goto end_rename;
+	}
 
 	if (IS_DIRSYNC(old.dir) || IS_DIRSYNC(new.dir))
 		ext4_handle_sync(handle);


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

* Re: [PATCH] ext4: fix bh leak on error paths in ext4_rename() and ext4_cross_rename()
  2015-03-03 11:17 [PATCH] ext4: fix bh leak on error paths in ext4_rename() and ext4_cross_rename() Konstantin Khlebnikov
@ 2015-03-04 15:03 ` Jan Kara
  2015-04-02 20:36 ` Theodore Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2015-03-04 15:03 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Andreas Dilger, linux-ext4, Theodore Ts'o, linux-kernel

On Tue 03-03-15 14:17:19, Konstantin Khlebnikov wrote:
> Release references to buffer-heads if ext4_journal_start() fails.
  Looks good. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> 
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> Fixes: 5b61de757535 ("ext4: start handle at least possible moment when renaming files")
> ---
>  fs/ext4/namei.c |   21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 28fe71a2904c..8110dd20ad3f 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -3264,12 +3264,18 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
>  		   EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2);
>  	if (!(flags & RENAME_WHITEOUT)) {
>  		handle = ext4_journal_start(old.dir, EXT4_HT_DIR, credits);
> -		if (IS_ERR(handle))
> -			return PTR_ERR(handle);
> +		if (IS_ERR(handle)) {
> +			retval = PTR_ERR(handle);
> +			handle = NULL;
> +			goto end_rename;
> +		}
>  	} else {
>  		whiteout = ext4_whiteout_for_rename(&old, credits, &handle);
> -		if (IS_ERR(whiteout))
> -			return PTR_ERR(whiteout);
> +		if (IS_ERR(whiteout)) {
> +			retval = PTR_ERR(whiteout);
> +			whiteout = NULL;
> +			goto end_rename;
> +		}
>  	}
>  
>  	if (IS_DIRSYNC(old.dir) || IS_DIRSYNC(new.dir))
> @@ -3433,8 +3439,11 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	handle = ext4_journal_start(old.dir, EXT4_HT_DIR,
>  		(2 * EXT4_DATA_TRANS_BLOCKS(old.dir->i_sb) +
>  		 2 * EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2));
> -	if (IS_ERR(handle))
> -		return PTR_ERR(handle);
> +	if (IS_ERR(handle)) {
> +		retval = PTR_ERR(handle);
> +		handle = NULL;
> +		goto end_rename;
> +	}
>  
>  	if (IS_DIRSYNC(old.dir) || IS_DIRSYNC(new.dir))
>  		ext4_handle_sync(handle);
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* Re: [PATCH] ext4: fix bh leak on error paths in ext4_rename() and ext4_cross_rename()
  2015-03-03 11:17 [PATCH] ext4: fix bh leak on error paths in ext4_rename() and ext4_cross_rename() Konstantin Khlebnikov
  2015-03-04 15:03 ` Jan Kara
@ 2015-04-02 20:36 ` Theodore Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2015-04-02 20:36 UTC (permalink / raw)
  To: Konstantin Khlebnikov; +Cc: Andreas Dilger, linux-ext4, linux-kernel

On Tue, Mar 03, 2015 at 02:17:19PM +0300, Konstantin Khlebnikov wrote:
> Release references to buffer-heads if ext4_journal_start() fails.
> 
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> Fixes: 5b61de757535 ("ext4: start handle at least possible moment when renaming files")

Thanks, applied.

						- Ted

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

end of thread, other threads:[~2015-04-02 20:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-03 11:17 [PATCH] ext4: fix bh leak on error paths in ext4_rename() and ext4_cross_rename() Konstantin Khlebnikov
2015-03-04 15:03 ` Jan Kara
2015-04-02 20:36 ` Theodore Ts'o

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