Skip to content

Commit 402074f

Browse files
Dan Carpentervireshk
authored andcommitted
opp: core: Fix off by one in dev_pm_opp_get_bw()
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 <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent b89c0ed commit 402074f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/opp/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ unsigned long dev_pm_opp_get_bw(struct dev_pm_opp *opp, bool peak, int index)
121121
return 0;
122122
}
123123

124-
if (index > opp->opp_table->path_count)
124+
if (index >= opp->opp_table->path_count)
125125
return 0;
126126

127127
if (!opp->bandwidth)

0 commit comments

Comments
 (0)