From 0b8dcba50cfc425d40500fa55439f679b5f10844 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Thu, 12 Oct 2023 14:22:01 +0200 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/c/flashrom/+/78300 Tested-by: build bot (Jenkins) Reviewed-by: Anastasia Klimchuk --- ich_descriptors.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ich_descriptors.c b/ich_descriptors.c index a2a99bd0b..4b440ed7b 100644 --- a/ich_descriptors.c +++ b/ich_descriptors.c @@ -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; }