opp: core: Fix off by one in dev_pm_opp_get_bw()
Subsystems (2)
PATCH 1/1 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]>
--- drivers/opp/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/opp/core.c +1 -1
@@ -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)
Signature · 1 line
2.45.2
Viresh Kumar
AppliedQuoted 15 lines · Dan Carpenter
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]>--- drivers/opp/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/opp/core.c +0
-0
drivers/opp/core.c unsigned long dev_pm_opp_get_bw(struct dev_pm_opp *opp, bool peak, int index) · line 127
Quoted 8 lines
drivers/opp/core.c +1
-1@@ -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)
Applied. Thanks.
Signature · 1 line
viresh