Commit 7071b715 authored by Konstantin Khlebnikov's avatar Konstantin Khlebnikov Committed by Theodore Ts'o

ext4: fix bh leak on error paths in ext4_rename() and ext4_cross_rename()

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

Fixes: 5b61de75 ("ext4: start handle at least possible moment when renaming files")
Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
parent 1efff914
...@@ -3264,12 +3264,18 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -3264,12 +3264,18 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2); EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2);
if (!(flags & RENAME_WHITEOUT)) { if (!(flags & RENAME_WHITEOUT)) {
handle = ext4_journal_start(old.dir, EXT4_HT_DIR, credits); handle = ext4_journal_start(old.dir, EXT4_HT_DIR, credits);
if (IS_ERR(handle)) if (IS_ERR(handle)) {
return PTR_ERR(handle); retval = PTR_ERR(handle);
handle = NULL;
goto end_rename;
}
} else { } else {
whiteout = ext4_whiteout_for_rename(&old, credits, &handle); whiteout = ext4_whiteout_for_rename(&old, credits, &handle);
if (IS_ERR(whiteout)) if (IS_ERR(whiteout)) {
return PTR_ERR(whiteout); retval = PTR_ERR(whiteout);
whiteout = NULL;
goto end_rename;
}
} }
if (IS_DIRSYNC(old.dir) || IS_DIRSYNC(new.dir)) 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, ...@@ -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, handle = ext4_journal_start(old.dir, EXT4_HT_DIR,
(2 * EXT4_DATA_TRANS_BLOCKS(old.dir->i_sb) + (2 * EXT4_DATA_TRANS_BLOCKS(old.dir->i_sb) +
2 * EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2)); 2 * EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2));
if (IS_ERR(handle)) if (IS_ERR(handle)) {
return PTR_ERR(handle); retval = PTR_ERR(handle);
handle = NULL;
goto end_rename;
}
if (IS_DIRSYNC(old.dir) || IS_DIRSYNC(new.dir)) if (IS_DIRSYNC(old.dir) || IS_DIRSYNC(new.dir))
ext4_handle_sync(handle); ext4_handle_sync(handle);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment