ext4: use IS_ERR() for error checking of path
authorHarshad Shirwadkar <harshadshirwadkar@gmail.com>
Tue, 27 Oct 2020 20:43:42 +0000 (13:43 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 28 Oct 2020 17:43:07 +0000 (13:43 -0400)
With this fix, fast commit recovery code uses IS_ERR() for path
returned by ext4_find_extent.

Fixes: 8016e29f4362 ("ext4: fast commit recovery path")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Link: https://lore.kernel.org/r/20201027204342.2794949-1-harshadshirwadkar@gmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/fast_commit.c

index 3ee43fd6d5aa7056e3b74ba0e9e152ad61dc0d53..8d43058386c3037f0525b85bda4c5d14d775c6b1 100644 (file)
@@ -1616,8 +1616,10 @@ static int ext4_fc_replay_add_range(struct super_block *sb,
                if (ret == 0) {
                        /* Range is not mapped */
                        path = ext4_find_extent(inode, cur, NULL, 0);
-                       if (!path)
-                               continue;
+                       if (IS_ERR(path)) {
+                               iput(inode);
+                               return 0;
+                       }
                        memset(&newex, 0, sizeof(newex));
                        newex.ee_block = cpu_to_le32(cur);
                        ext4_ext_store_pblock(