mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
sched/uclamp: Reject negative values in cpu_uclamp_write()
commit b562d140649966d4daedd0483a8fe59ad3bb465a upstream.
The check to ensure that the new written value into cpu.uclamp.{min,max}
is within range, [0:100], wasn't working because of the signed
comparison
7301 if (req.percent > UCLAMP_PERCENT_SCALE) {
7302 req.ret = -ERANGE;
7303 return req;
7304 }
# echo -1 > cpu.uclamp.min
# cat cpu.uclamp.min
42949671.96
Cast req.percent into u64 to force the comparison to be unsigned and
work as intended in capacity_from_percent().
# echo -1 > cpu.uclamp.min
sh: write error: Numerical result out of range
Fixes: 2480c09313 ("sched/uclamp: Extend CPU's cgroup controller")
Signed-off-by: Qais Yousef <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
115402ee80
commit
9f6f61c61a
1 changed files with 1 additions and 1 deletions
|
|
@ -7250,7 +7250,7 @@ capacity_from_percent(char *buf)
|
|||
&req.percent);
|
||||
if (req.ret)
|
||||
return req;
|
||||
if (req.percent > UCLAMP_PERCENT_SCALE) {
|
||||
if ((u64)req.percent > UCLAMP_PERCENT_SCALE) {
|
||||
req.ret = -ERANGE;
|
||||
return req;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue