1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

ich_descriptors: Fix debug print

Allow nm, the number of flash masters, to be equal to
ARRAY_SIZE(master_names). The previous logic was probably overlooked
when ich_number_of_masters() was introduced. The loop below makes sure
that it doesn't access the master_names array out of bounds.

Change-Id: Ib9276a6c29952487db6e60fb583942c0f24cd6ef
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/78300
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
Patrick Rudolph 2023-10-12 14:22:01 +02:00 committed by Anastasia Klimchuk
parent fba29da188
commit 0b8dcba50c

View File

@ -493,9 +493,9 @@ void prettyprint_ich_descriptor_master(const enum ich_chipset cs, const struct i
const char *const master_names[] = {
"BIOS", "ME", "GbE", "unknown", "EC",
};
if (nm >= (ssize_t)ARRAY_SIZE(master_names)) {
msg_pdbg2("%s: number of masters too high (%d).\n", __func__,
desc->content.NM + 1);
if (nm > (ssize_t)ARRAY_SIZE(master_names)) {
msg_pdbg2("%s: number of masters too high (%zd).\n", __func__, nm);
return;
}