ext4: initialize err_blk before calling __ext4_get_inode_loc
authorHarshad Shirwadkar <harshadshirwadkar@gmail.com>
Wed, 1 Dec 2021 16:34:21 +0000 (08:34 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 09:54:27 +0000 (10:54 +0100)
commit c27c29c6af4f3f4ce925a2111c256733c5a5b430 upstream.

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>
Link: https://lore.kernel.org/r/20211201163421.2631661-1-harshads@google.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/inode.c

index 317aa1b90fb955321523061ace3d6f295793f962..a6ee5399526b6676a1e80bd8658c6ddc93401b12 100644 (file)
@@ -4445,7 +4445,7 @@ has_buffer:
 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, iloc, 0,
@@ -4460,7 +4460,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;
 
        /* We have all inode data except xattrs in memory here. */