]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
depmod: Support modules.order with duplicate lines
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 29 Sep 2024 19:29:56 +0000 (21:29 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 1 Oct 2024 14:12:26 +0000 (09:12 -0500)
If the same line exists multiple times in modules.order, consider only
the first, since this is the earliest position requested.

This also makes sure that index iterator never turns positive or would
ever trigger a signed integer overflow.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/158
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
tools/depmod.c

index 02a89046488a49f5016483520dce15c933443067..876c46d373af37690130bfa73b4fd421268474b7 100644 (file)
@@ -1484,7 +1484,7 @@ static void depmod_modules_sort(struct depmod *depmod)
                }
                line[len - 1] = '\0';
                mod = hash_find(depmod->modules_by_uncrelpath, line);
-               if (mod == NULL)
+               if (mod == NULL || mod->sort_idx < 0)
                        continue;
                mod->sort_idx = i++;
        }