From: Jingkai Tan <contact@jingk.ai> mainline inclusion from mainline-v7.1-rc1 commit 638a95168fd53a911201681cd5e55c7965b20733 category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/9134 CVE: NA Reference: https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commi... ---------------------------------------------------------------------- The inner loop in flatten_lpi_states() that combines composite LPI states can increment flat_state_cnt multiple times within the loop. The condition that guards this (checks bounds against ACPI_PROCESSOR _MAX_POWER) occurs at the top of the outer loop. flat_state_cnt might exceed ACPI_PROCESSOR_MAX_POWER if it is incremented multiple times within the inner loop between outer loop iterations. Add a bounds check after the increment inside the inner loop so that it breaks out when flat_state_cnt reaches ACPI_PROCESSOR_MAX_POWER. The existing check in the outer loop will then handle the warning. Signed-off-by: Jingkai Tan <contact@jingk.ai> Reviewed-by: Sudeep Holla <sudeep.holla@kernel.org> Link: https://patch.msgid.link/20260305213831.53985-1-contact@jingk.ai Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Huisong Li <lihuisong@huawei.com> Signed-off-by: Hongye Lin <linhongye@h-partners.com> --- drivers/acpi/processor_idle.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 9cc372e98f9b..ef75bf5bea82 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -1077,6 +1077,8 @@ static unsigned int flatten_lpi_states(struct acpi_processor *pr, stash_composite_state(curr_level, flpi); flat_state_cnt++; flpi++; + if (flat_state_cnt >= ACPI_PROCESSOR_MAX_POWER) + break; } } } -- 2.33.0