Merge tag 'spi-fix-v5.15-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/brooni...
[linux-2.6-microblaze.git] / fs / ext4 / extents.c
index c0de30f..0e02571 100644 (file)
@@ -5916,7 +5916,7 @@ void ext4_ext_replay_shrink_inode(struct inode *inode, ext4_lblk_t end)
 }
 
 /* Check if *cur is a hole and if it is, skip it */
-static void skip_hole(struct inode *inode, ext4_lblk_t *cur)
+static int skip_hole(struct inode *inode, ext4_lblk_t *cur)
 {
        int ret;
        struct ext4_map_blocks map;
@@ -5925,9 +5925,12 @@ static void skip_hole(struct inode *inode, ext4_lblk_t *cur)
        map.m_len = ((inode->i_size) >> inode->i_sb->s_blocksize_bits) - *cur;
 
        ret = ext4_map_blocks(NULL, inode, &map, 0);
+       if (ret < 0)
+               return ret;
        if (ret != 0)
-               return;
+               return 0;
        *cur = *cur + map.m_len;
+       return 0;
 }
 
 /* Count number of blocks used by this inode and update i_blocks */
@@ -5976,7 +5979,9 @@ int ext4_ext_replay_set_iblocks(struct inode *inode)
         * iblocks by total number of differences found.
         */
        cur = 0;
-       skip_hole(inode, &cur);
+       ret = skip_hole(inode, &cur);
+       if (ret < 0)
+               goto out;
        path = ext4_find_extent(inode, cur, NULL, 0);
        if (IS_ERR(path))
                goto out;
@@ -5995,8 +6000,12 @@ int ext4_ext_replay_set_iblocks(struct inode *inode)
                }
                cur = max(cur + 1, le32_to_cpu(ex->ee_block) +
                                        ext4_ext_get_actual_len(ex));
-               skip_hole(inode, &cur);
-
+               ret = skip_hole(inode, &cur);
+               if (ret < 0) {
+                       ext4_ext_drop_refs(path);
+                       kfree(path);
+                       break;
+               }
                path2 = ext4_find_extent(inode, cur, NULL, 0);
                if (IS_ERR(path2)) {
                        ext4_ext_drop_refs(path);