ext4: fix bh leak on error paths in ext4_rename() and ext4_cross_rename()
PATCH 1/1 ext4: fix bh leak on error paths in ext4_rename() and ext4_cross_rename()
Release references to buffer-heads if ext4_journal_start() fails.
Signed-off-by Konstantin Khlebnikov <[email protected]>
Fixes 5b61de757535 ("ext4: start handle at least possible moment when renaming files")
--- fs/ext4/namei.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
fs/ext4/namei.c +15 -6
@@ -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);
Quoted 1 line · Konstantin Khlebnikov
Release references to buffer-heads if
ext4_journal_start()fails.
Looks good. You can add:
Reviewed-by Jan Kara <[email protected]>
Honza
Quoted 53 lines
Signed-off-by Konstantin Khlebnikov <[email protected]>Fixes 5b61de757535 ("ext4: start handle at least possible moment when renaming files")--- fs/ext4/namei.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)fs/ext4/namei.c +15
-7@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 4 lines · Konstantin Khlebnikov
Release references to buffer-heads if
ext4_journal_start()fails.Signed-off-by Konstantin Khlebnikov <[email protected]>Fixes 5b61de757535 ("ext4: start handle at least possible moment when renaming files")
Thanks, applied.
- Ted