Skip to contentSkip to conversation

ext4: initialize err_blk before calling __ext4_get_inode_loc

PATCH Applied Harshad Shirwadkar 2 participants 2 messages Dec 1, 2021 – Dec 27, 2021 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: initialize err_blk before calling __ext4_get_inode_loc

From: Harshad Shirwadkar <[email protected]>

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.

---
 fs/ext4/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ext4/inode.c +2 -2
index bfd3545f1e5d..fbdd2dda57ae 100644
@@ -4523,7 +4523,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,
@@ -4538,7 +4538,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,
Signature · 1 line
2.34.0.rc2.393.gf8c9666880-goog
maintainer Applied
#1 lore raw
Quoted 8 lines · Harshad Shirwadkar

From: Harshad Shirwadkar <[email protected]>

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.

[...]

Applied, thanks!

[1/1] ext4: initialize err_blk before calling __ext4_get_inode_loc

      commit: 613da7163720054004f596e5f5230753b50a7f45

Best regards,

Signature · 1 line
Theodore Ts'o <[email protected]>