diff mbox series

ext4: initialize err_blk before calling __ext4_get_inode_loc

Message ID 20211201163421.2631661-1-harshads@google.com
State Awaiting Upstream
Headers show
Series ext4: initialize err_blk before calling __ext4_get_inode_loc | expand

Commit Message

harshad shirwadkar Dec. 1, 2021, 4:34 p.m. UTC
From: Harshad Shirwadkar <harshadshirwadkar@gmail.com>

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 <dan.carpenter@oracle.com>
Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
---
 fs/ext4/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Theodore Ts'o Dec. 27, 2021, 5:34 a.m. UTC | #1
On Wed, 1 Dec 2021 08:34:21 -0800, Harshad Shirwadkar wrote:
> From: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
> 
> 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,
diff mbox series

Patch

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index bfd3545f1e5d..fbdd2dda57ae 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -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,