[PATCH] lmb: add a check to prevent memory overrun
Sughosh Ganu
sughosh.ganu at linaro.org
Mon Oct 21 19:18:20 CEST 2024
When printing the LMB flags for a memory region, there is a need to
check that the array index that is computed is a sane value. Put a
noisy assert in case this check fails, as that implies something with
the LMB code is not working as expected.
Reported-by: Coverity (CID 510463)
Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
---
lib/lmb.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/lmb.c b/lib/lmb.c
index 7e90f178763..a7298dfd673 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -76,6 +76,7 @@ static void lmb_print_region_flags(enum lmb_flags flags)
do {
bitpos = flags ? fls(flags) - 1 : 0;
+ assert_noisy(bitpos < ARRAY_SIZE(flag_str));
printf("%s", flag_str[bitpos]);
flags &= ~(1ull << bitpos);
puts(flags ? ", " : "\n");
--
2.34.1
More information about the U-Boot
mailing list