Skip to content

Commit

Permalink
ext4: lost matching-pair of trace in ext4_truncate
Browse files Browse the repository at this point in the history
[ Upstream commit 9a5d265 ]

It should call trace exit in all return path for ext4_truncate.

Signed-off-by: zhengliang <zhengliang6@huawei.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Reviewed-by: Ritesh Harjani <riteshh@linux.ibm.com>
Link: https://lore.kernel.org/r/20200701083027.45996-1-zhengliang6@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Stable-dep-of: a71248b ("ext4: fix use-after-free in ext4_orphan_cleanup")
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
z00448126 authored and Sasha Levin committed Jan 18, 2023
1 parent b283420 commit 06c791c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4551,7 +4551,7 @@ int ext4_truncate(struct inode *inode)
trace_ext4_truncate_enter(inode);

if (!ext4_can_truncate(inode))
return 0;
goto out_trace;

ext4_clear_inode_flag(inode, EXT4_INODE_EOFBLOCKS);

Expand All @@ -4562,16 +4562,14 @@ int ext4_truncate(struct inode *inode)
int has_inline = 1;

err = ext4_inline_data_truncate(inode, &has_inline);
if (err)
return err;
if (has_inline)
return 0;
if (err || has_inline)
goto out_trace;
}

/* If we zero-out tail of the page, we have to create jinode for jbd2 */
if (inode->i_size & (inode->i_sb->s_blocksize - 1)) {
if (ext4_inode_attach_jinode(inode) < 0)
return 0;
goto out_trace;
}

if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
Expand All @@ -4580,8 +4578,10 @@ int ext4_truncate(struct inode *inode)
credits = ext4_blocks_for_truncate(inode);

handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, credits);
if (IS_ERR(handle))
return PTR_ERR(handle);
if (IS_ERR(handle)) {
err = PTR_ERR(handle);
goto out_trace;
}

if (inode->i_size & (inode->i_sb->s_blocksize - 1))
ext4_block_truncate_page(handle, mapping, inode->i_size);
Expand Down Expand Up @@ -4630,6 +4630,7 @@ int ext4_truncate(struct inode *inode)
ext4_mark_inode_dirty(handle, inode);
ext4_journal_stop(handle);

out_trace:
trace_ext4_truncate_exit(inode);
return err;
}
Expand Down

0 comments on commit 06c791c

Please sign in to comment.