From ea16db2c0e3b5c3f3de82b517af9f91dc3e7de4e Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Mon, 30 Sep 2024 17:05:23 +0200 Subject: [PATCH] depmod: Check amount of memories The code does not support 65535 or more modules. Since this value is probably never reached, add a proper check after array building and do not rely solely on an assert later in code path. 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, 2 insertions(+) diff --git a/tools/depmod.c b/tools/depmod.c index 876c46d3..4718f4d1 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -1428,6 +1428,8 @@ static int depmod_modules_build_array(struct depmod *depmod) if (err < 0) return err; } + if (depmod->modules.count >= UINT16_MAX) + return -ERANGE; return 0; }