Whamcloud - gitweb
e2fsck: skip sorting extents if there are no valid extents
authorHarshad Shirwadkar <harshadshirwadkar@gmail.com>
Wed, 17 Nov 2021 16:50:15 +0000 (08:50 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 3 Dec 2021 19:56:18 +0000 (14:56 -0500)
At the end of a fast commit replay, e2fsck tries merging extents in a
inode. This patch fixes a bug in this logic where we were continuing
this action even if there were no extents to merge resulting in
accessing illegal memory.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
e2fsck/journal.c

index fe4e018..2e86723 100644 (file)
@@ -464,6 +464,9 @@ static void ex_sort_and_merge(struct extent_list *list)
                }
        }
 
+       if (list->count == 0)
+               return;
+
        /* Now sort by logical offset */
        qsort(list->extents, list->count, sizeof(list->extents[0]),
                ex_compar);