From: Tobias Stoeckmann Date: Sun, 29 Sep 2024 19:29:56 +0000 (+0200) Subject: depmod: Support modules.order with duplicate lines X-Git-Tag: v34~276 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1186faeac14763d11872ec93b572738a7a7e09a;p=thirdparty%2Fkmod.git 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 --- 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++; }