Skip to content

Commit

Permalink
opp: core: Fix off by one in dev_pm_opp_get_bw()
Browse files Browse the repository at this point in the history
The "opp->bandwidth" array has "opp->opp_table->path_count" number of
elements.  It's allocated in _opp_allocate().  So this > needs to be >=
to prevent an out of bounds access.

Fixes: d78653dcd8bf ("opp: core: implement dev_pm_opp_get_bw")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
  • Loading branch information
Dan Carpenter authored and Viresh Kumar committed Dec 23, 2024
1 parent b89c0ed commit 402074f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/opp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ unsigned long dev_pm_opp_get_bw(struct dev_pm_opp *opp, bool peak, int index)
return 0;
}

if (index > opp->opp_table->path_count)
if (index >= opp->opp_table->path_count)
return 0;

if (!opp->bandwidth)
Expand Down

0 comments on commit 402074f

Please sign in to comment.