]> git.baikalelectronics.ru Git - kernel.git/commit
intel_pstate: Fix possible overflow complained by Coverity
authorChen Yu <yu.c.chen@intel.com>
Wed, 29 Jul 2015 15:53:10 +0000 (23:53 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 31 Jul 2015 21:25:16 +0000 (23:25 +0200)
commit53fec97eee08955d9a4c5b7e99419e6abecfeb0d
tree13ff609371f0ba7949d392d32512a01680b0aa07
parent873fb63c31c3bd3e8468b9ebe54f9d3aee181602
intel_pstate: Fix possible overflow complained by Coverity

Coverity scanning performed on intel_pstate.c shows possible
overflow when doing left shifting:
val = pstate << 8;
since pstate is of type integer, while val is of u64, left shifting
pstate might lead to potential loss of upper bits. Say, if pstate equals
0x4000 0000, after pstate << 8 we will get zero assigned to val.
Although pstate will not likely be that big, this patch cast the left
operand to u64 before performing the left shift, to avoid complaining
from Coverity.

Reported-by: Coquard, Christophe <christophe.coquard@intel.com>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/intel_pstate.c