Skip to content

Commit

Permalink
ext4: initialize err_blk before calling __ext4_get_inode_loc
Browse files Browse the repository at this point in the history
It is not guaranteed that __ext4_get_inode_loc will definitely set
err_blk pointer when it returns EIO. To avoid using uninitialized
variables, let's first set err_blk to 0.

Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Harshad Shirwadkar <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Theodore Ts'o <[email protected]>
Cc: [email protected]
  • Loading branch information
harshadjs authored and tytso committed Jan 10, 2022
1 parent 8c80fb3 commit c27c29c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4524,7 +4524,7 @@ static int __ext4_get_inode_loc(struct super_block *sb, unsigned long ino,
static int __ext4_get_inode_loc_noinmem(struct inode *inode,
struct ext4_iloc *iloc)
{
ext4_fsblk_t err_blk;
ext4_fsblk_t err_blk = 0;
int ret;

ret = __ext4_get_inode_loc(inode->i_sb, inode->i_ino, NULL, iloc,
Expand All @@ -4539,7 +4539,7 @@ static int __ext4_get_inode_loc_noinmem(struct inode *inode,

int ext4_get_inode_loc(struct inode *inode, struct ext4_iloc *iloc)
{
ext4_fsblk_t err_blk;
ext4_fsblk_t err_blk = 0;
int ret;

ret = __ext4_get_inode_loc(inode->i_sb, inode->i_ino, inode, iloc,
Expand Down

0 comments on commit c27c29c

Please sign in to comment.