|SUCCESS| power: fix off-by-one in uncore env bounds check
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Fri Apr 24 23:47:54 CEST 2026
Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/163280
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-04-24
Here is my plain text review of the patch:
commit ac1edcb6621a ("power: refactor uncore power management API")
Author: Denis Sergeev <denserg.edu at gmail.com>
power: fix off-by-one in uncore env bounds check
This patch fixes an off-by-one error in the bounds checking logic of
rte_power_set_uncore_env() that could lead to an out-of-bounds array
access.
> 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) {
Good catch on the off-by-one error. The fix correctly changes the bounds
check from '<=' to '<' to prevent accessing uncore_env_str[4] when
RTE_DIM(uncore_env_str) equals 4.
However, does this code handle the case where env is still out of bounds
after the fix? If env >= RTE_DIM(uncore_env_str), the condition fails and
execution continues past this block. Does the function then return an error
or proceed with an invalid env value? Looking at the control flow, if the
condition is false, the function appears to fall through without setting
rte_uncore_power_pmd_ops, potentially leaving it in an undefined state or
as NULL. Should there be an explicit error return when env is out of
bounds?
Also, in rte_power_uncore_init() which already uses the correct '<'
operator, is there similar error handling for out-of-bounds env values
that should be mirrored here for consistency?
More information about the test-report
mailing list