mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-19 19:34:35 +00:00
lmb: add a check to prevent memory overrun
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@linaro.org>
This commit is contained in:
parent
0d0864acfc
commit
c3cf0dc64f
1 changed files with 1 additions and 0 deletions
|
@ -76,6 +76,7 @@ static void lmb_print_region_flags(enum lmb_flags flags)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
bitpos = flags ? fls(flags) - 1 : 0;
|
bitpos = flags ? fls(flags) - 1 : 0;
|
||||||
|
assert_noisy(bitpos < ARRAY_SIZE(flag_str));
|
||||||
printf("%s", flag_str[bitpos]);
|
printf("%s", flag_str[bitpos]);
|
||||||
flags &= ~(1ull << bitpos);
|
flags &= ~(1ull << bitpos);
|
||||||
puts(flags ? ", " : "\n");
|
puts(flags ? ", " : "\n");
|
||||||
|
|
Loading…
Add table
Reference in a new issue