|SUCCESS| power: fix off-by-one in uncore env bounds check

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Wed Jun 3 17:38:05 CEST 2026


Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/164868

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-06-03

commit 87c3a5b9f12e45a6d8b7c3e2f1a9b8c7d6e5f4a3
Author: Denis Sergeev <denserg.edu at gmail.com>

power: fix off-by-one in uncore env bounds check

The patch corrects an off-by-one error in the bounds check for the env
parameter in rte_power_set_uncore_env(), where '<=' was incorrectly used
instead of '<' when comparing against RTE_DIM(uncore_env_str).

> diff --git a/lib/power/rte_power_uncore.c b/lib/power/rte_power_uncore.c
> index 25bdb113c5..b50e09a2ad 100644
> --- a/lib/power/rte_power_uncore.c
> +++ b/lib/power/rte_power_uncore.c
> @@ -67,7 +67,7 @@ rte_power_set_uncore_env(enum rte_uncore_power_mgmt_env env)
>  		 */
>  		env = RTE_UNCORE_PM_ENV_INTEL_UNCORE;
>  
> -	if (env <= RTE_DIM(uncore_env_str)) {
> +	if (env < RTE_DIM(uncore_env_str)) {
>  		RTE_TAILQ_FOREACH(ops, &uncore_ops_list, next)
>  			if (strncmp(ops->name, uncore_env_str[env],
>  				RTE_POWER_UNCORE_DRIVER_NAMESZ) == 0) {

The fix looks correct.  With RTE_DIM(uncore_env_str) returning 4, the
valid array indices are 0 through 3.  The previous condition allowed
env=4 to pass, which would access uncore_env_str[4] illegally.  Changing
to '<' properly restricts env to 0..3.

This matches the pattern already used in rte_power_uncore_init() in the
same source file, improving consistency across the codebase.


More information about the test-report mailing list