All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: fix potential error in ext4_do_update_inode
@ 2021-03-12  6:50 Shijie Luo
  2021-03-12 12:50 ` Jan Kara
  0 siblings, 1 reply; 3+ messages in thread
From: Shijie Luo @ 2021-03-12  6:50 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso, jack, luoshijie1

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>
---
 fs/ext4/inode.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 650c5acd2f2d..8074ae0e976d 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5026,7 +5026,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;
@@ -5138,9 +5138,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");
-- 
2.19.1


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

* Re: [PATCH] ext4: fix potential error in ext4_do_update_inode
  2021-03-12  6:50 [PATCH] ext4: fix potential error in ext4_do_update_inode Shijie Luo
@ 2021-03-12 12:50 ` Jan Kara
  2021-03-21  4:26   ` Theodore Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2021-03-12 12:50 UTC (permalink / raw)
  To: Shijie Luo; +Cc: linux-ext4, tytso, jack

On Fri 12-03-21 01:50:51, Shijie Luo wrote:
> 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>

Yeah, looks good. Once ext4_handle_dirty_metadata() fails, the journal is
aborted anyway so we are unlikely to do anything useful with the
filesystem. Feel free to add:

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

								Honza

> ---
>  fs/ext4/inode.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 650c5acd2f2d..8074ae0e976d 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -5026,7 +5026,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;
> @@ -5138,9 +5138,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");
> -- 
> 2.19.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH] ext4: fix potential error in ext4_do_update_inode
  2021-03-12 12:50 ` Jan Kara
@ 2021-03-21  4:26   ` Theodore Ts'o
  0 siblings, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2021-03-21  4:26 UTC (permalink / raw)
  To: Jan Kara; +Cc: Shijie Luo, linux-ext4

On Fri, Mar 12, 2021 at 01:50:55PM +0100, Jan Kara wrote:
> On Fri 12-03-21 01:50:51, Shijie Luo wrote:
> > 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>
> 
> Yeah, looks good. Once ext4_handle_dirty_metadata() fails, the journal is
> aborted anyway so we are unlikely to do anything useful with the
> filesystem. Feel free to add:
> 
> Reviewed-by: Jan Kara <jack@suse.cz>

Thanks, applied.

					- Ted

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

end of thread, other threads:[~2021-03-21  4:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-12  6:50 [PATCH] ext4: fix potential error in ext4_do_update_inode Shijie Luo
2021-03-12 12:50 ` Jan Kara
2021-03-21  4:26   ` Theodore Ts'o

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.