diff options
| author | Sughosh Ganu <[email protected]> | 2024-10-21 22:48:20 +0530 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2024-10-29 12:09:49 -0600 |
| commit | c3cf0dc64f1c39bc10530ef649fd7bf147e70720 (patch) | |
| tree | 9e971ba61e73ff3195f92014e47225ee7bea6d43 /lib | |
| parent | 0d0864acfc94996fe080a354a869bbf7a66f5991 (diff) | |
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 <[email protected]>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/lmb.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/lmb.c b/lib/lmb.c index eec99c185ee..bf261db999e 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"); |
