From: Harshad Shirwadkar Date: Wed, 17 Nov 2021 16:50:15 +0000 (-0800) Subject: e2fsck: skip sorting extents if there are no valid extents X-Git-Tag: v1.46.5~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54183fea07676d185b2c169c45a7c1adc7e3e26e;p=thirdparty%2Fe2fsprogs.git e2fsck: skip sorting extents if there are no valid extents 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 --- diff --git a/e2fsck/journal.c b/e2fsck/journal.c index fe4e018df..2e867234b 100644 --- a/e2fsck/journal.c +++ b/e2fsck/journal.c @@ -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);