diff options
author | Shijie Luo <luoshijie1@huawei.com> | 2021-03-12 01:50:51 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-03-24 11:05:06 +0100 |
commit | fe778c33aaa9c6ca0d9e90c16d07dd01cd3d8785 (patch) | |
tree | 77d6bcaa05667b9c9fa4eed36a2d219ed1ba3d20 /fs | |
parent | 470f69cb3742e4c774ff2c89f6dbc691ba702926 (diff) | |
download | linux-stable-fe778c33aaa9c6ca0d9e90c16d07dd01cd3d8785.tar.gz linux-stable-fe778c33aaa9c6ca0d9e90c16d07dd01cd3d8785.tar.bz2 linux-stable-fe778c33aaa9c6ca0d9e90c16d07dd01cd3d8785.zip |
ext4: fix potential error in ext4_do_update_inode
commit 7d8bd3c76da1d94b85e6c9b7007e20e980bfcfe6 upstream.
If set_large_file = 1 and errors occur in ext4_handle_dirty_metadata(),
the error code will be overridden, go to out_brelse to avoid this
situation.
Signed-off-by: Shijie Luo <luoshijie1@huawei.com>
Link: https://lore.kernel.org/r/20210312065051.36314-1-luoshijie1@huawei.com
Cc: stable@kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/inode.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index f631abb507c3..ad6a1282a5cd 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5130,7 +5130,7 @@ static int ext4_do_update_inode(handle_t *handle, struct ext4_inode_info *ei = EXT4_I(inode); struct buffer_head *bh = iloc->bh; struct super_block *sb = inode->i_sb; - int err = 0, rc, block; + int err = 0, block; int need_datasync = 0, set_large_file = 0; uid_t i_uid; gid_t i_gid; @@ -5240,9 +5240,9 @@ static int ext4_do_update_inode(handle_t *handle, bh->b_data); BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); - rc = ext4_handle_dirty_metadata(handle, NULL, bh); - if (!err) - err = rc; + err = ext4_handle_dirty_metadata(handle, NULL, bh); + if (err) + goto out_brelse; ext4_clear_inode_state(inode, EXT4_STATE_NEW); if (set_large_file) { BUFFER_TRACE(EXT4_SB(sb)->s_sbh, "get write access"); |