From a1186faeac14763d11872ec93b572738a7a7e09a Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Sun, 29 Sep 2024 21:29:56 +0200 Subject: [PATCH] depmod: Support modules.order with duplicate lines 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 Reviewed-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/158 Signed-off-by: Lucas De Marchi --- tools/depmod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/depmod.c b/tools/depmod.c index 02a89046..876c46d3 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -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++; } -- 2.47.3