From a431787f949b34fe6ce3d8cbec3170b63bea0122 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 --- 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; }