Skip to content

Commit 638a951

Browse files
xlanorrafaeljw
authored andcommitted
ACPI: processor: idle: Add missing bounds check in flatten_lpi_states()
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>
1 parent 1f318b9 commit 638a951

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/acpi/processor_idle.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,8 @@ static unsigned int flatten_lpi_states(struct acpi_processor *pr,
10681068
stash_composite_state(curr_level, flpi);
10691069
flat_state_cnt++;
10701070
flpi++;
1071+
if (flat_state_cnt >= ACPI_PROCESSOR_MAX_POWER)
1072+
break;
10711073
}
10721074
}
10731075
}

0 commit comments

Comments
 (0)