mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 17:23:56 -06:00
hw/misc: cast rpm to uint64_t
The value of an arithmetic expression 'rpm * NPCM7XX_MFT_PULSE_PER_REVOLUTION' is a subject to overflow because its operands are not cast to a larger data type before performing arithmetic. Thus, need to cast rpm to uint64_t. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Tigran Sogomonian <tsogomonian@astralinux.ru> Reviewed-by: Patrick Leis <venture@google.com> Reviewed-by: Hao Wu <wuhaotsh@google.com> Message-id: 20241226130311.1349-1-tsogomonian@astralinux.ru Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
906853e142
commit
593b910ebe
1 changed files with 3 additions and 2 deletions
|
@ -172,8 +172,9 @@ static NPCM7xxMFTCaptureState npcm7xx_mft_compute_cnt(
|
|||
* RPM = revolution/min. The time for one revlution (in ns) is
|
||||
* MINUTE_TO_NANOSECOND / RPM.
|
||||
*/
|
||||
count = clock_ns_to_ticks(clock, (60 * NANOSECONDS_PER_SECOND) /
|
||||
(rpm * NPCM7XX_MFT_PULSE_PER_REVOLUTION));
|
||||
count = clock_ns_to_ticks(clock,
|
||||
(uint64_t)(60 * NANOSECONDS_PER_SECOND) /
|
||||
((uint64_t)rpm * NPCM7XX_MFT_PULSE_PER_REVOLUTION));
|
||||
}
|
||||
|
||||
if (count > NPCM7XX_MFT_MAX_CNT) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue