linux-stable/drivers/cpuidle
C Cheng b510fbe3a7 cpuidle: Avoid potential overflow in integer multiplication
[ Upstream commit 88390dd788 ]

In detail:

In C language, when you perform a multiplication operation, if
both operands are of int type, the multiplication operation is
performed on the int type, and then the result is converted to
the target type. This means that if the product of int type
multiplication exceeds the range that int type can represent,
an overflow will occur even if you store the result in a
variable of int64_t type.

For a multiplication of two int values, it is better to use
mul_u32_u32() rather than s->exit_latency_ns = s->exit_latency *
NSEC_PER_USEC to avoid potential overflow happenning.

Signed-off-by: C Cheng <C.Cheng@mediatek.com>
Signed-off-by: Bo Ye <bo.ye@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
[ rjw: New subject ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-13 13:04:54 +02:00
..
governors cpuidle: haltpoll: Add trace points for guest_halt_poll_ns grow/shrink 2022-06-14 16:01:35 +02:00
Kconfig cpuidle: Add RISC-V SBI CPU idle driver 2022-03-10 09:29:51 -08:00
Kconfig.arm cpuidle: add ARCH_SUSPEND_POSSIBLE dependencies 2023-03-10 09:34:22 +01:00
Kconfig.mips
Kconfig.powerpc
Kconfig.riscv cpuidle: Add RISC-V SBI CPU idle driver 2022-03-10 09:29:51 -08:00
Makefile cpuidle: Add RISC-V SBI CPU idle driver 2022-03-10 09:29:51 -08:00
coupled.c cpuidle: coupled: Drop duplicate word from a comment 2022-08-31 20:54:01 +02:00
cpuidle-arm.c
cpuidle-at91.c treewide: Replace GPLv2 boilerplate/reference with SPDX - gpl-2.0_56.RULE (part 2) 2022-06-10 14:51:35 +02:00
cpuidle-big_little.c
cpuidle-calxeda.c
cpuidle-clps711x.c
cpuidle-cps.c
cpuidle-exynos.c
cpuidle-haltpoll.c cpuidle: haltpoll: Call cpuidle_poll_state_init() later 2022-03-09 19:59:45 +01:00
cpuidle-kirkwood.c treewide: Replace GPLv2 boilerplate/reference with SPDX - gpl-2.0_56.RULE (part 2) 2022-06-10 14:51:35 +02:00
cpuidle-mvebu-v7.c
cpuidle-powernv.c cpuidle: powernv: move from strlcpy() with unused retval to strscpy() 2022-08-31 21:09:54 +02:00
cpuidle-psci-domain.c cpuidle: psci: Move enabling OSI mode after power domains creation 2023-08-23 17:52:17 +02:00
cpuidle-psci.c context_tracking: Take IRQ eqs entrypoints over RCU 2022-07-05 13:32:59 -07:00
cpuidle-psci.h cpuidle: Factor-out power domain related code from PSCI domain driver 2022-03-10 09:29:44 -08:00
cpuidle-pseries.c powerpc/pseries: Rework lppaca_shared_proc() to avoid DEBUG_PREEMPT 2023-09-13 09:42:48 +02:00
cpuidle-qcom-spm.c firmware: qcom: scm: Drop cpumask parameter from set_boot_addr() 2022-02-03 21:54:48 -06:00
cpuidle-riscv-sbi.c RISC-V: Align SBI probe implementation with spec 2023-05-11 23:03:04 +09:00
cpuidle-tegra.c cpuidle: tegra: Check whether PMC is ready 2021-10-05 19:11:40 +02:00
cpuidle-ux500.c
cpuidle-zynq.c
cpuidle.c More power management updates for 5.20-rc1 2022-08-08 14:29:00 -07:00
cpuidle.h
driver.c cpuidle: Avoid potential overflow in integer multiplication 2024-04-13 13:04:54 +02:00
dt_idle_genpd.c cpuidle: dt_idle_genpd: Add helper function to remove genpd topology 2023-08-16 18:27:22 +02:00
dt_idle_genpd.h cpuidle: dt_idle_genpd: Add helper function to remove genpd topology 2023-08-16 18:27:22 +02:00
dt_idle_states.c cpuidle: dt: Return the correct numbers of parsed idle states 2022-12-31 13:31:55 +01:00
dt_idle_states.h
governor.c cpuidle: Remove redundant check in cpuidle_switch_governor() 2022-09-03 20:14:51 +02:00
poll_state.c
sysfs.c cpuidle: use default_groups in kobj_type 2022-01-05 18:31:17 +01:00