linux-stable/drivers/cpuidle
C Cheng 64a7694c85 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:01:43 +02:00
..
governors cpuidle: teo: Rename two local variables in teo_select() 2021-08-03 15:18:57 +02:00
Kconfig
Kconfig.arm cpuidle: Fix ARM_QCOM_SPM_CPUIDLE configuration 2021-04-08 19:54:14 +02:00
Kconfig.mips
Kconfig.powerpc
Makefile
coupled.c smp: Cleanup smp_call_function*() 2020-11-24 16:47:49 +01:00
cpuidle-arm.c
cpuidle-at91.c
cpuidle-big_little.c
cpuidle-calxeda.c
cpuidle-clps711x.c
cpuidle-cps.c
cpuidle-exynos.c
cpuidle-haltpoll.c
cpuidle-kirkwood.c
cpuidle-mvebu-v7.c
cpuidle-powernv.c
cpuidle-psci-domain.c cpuidle: psci: Iterate backwards over list in psci_pd_remove() 2023-03-22 13:31:36 +01:00
cpuidle-psci.c cpuidle: PSCI: Improve support for suspend-to-RAM for PSCI OSI mode 2022-06-09 10:22:33 +02:00
cpuidle-psci.h
cpuidle-pseries.c powerpc/pseries: Rework lppaca_shared_proc() to avoid DEBUG_PREEMPT 2023-09-19 12:22:42 +02:00
cpuidle-qcom-spm.c cpuidle: qcom: Add SPM register data for MSM8226 2021-06-16 20:03:26 +02:00
cpuidle-tegra.c cpuidle: tegra: Remove do_idle firmware call 2021-04-08 19:54:14 +02:00
cpuidle-ux500.c mfd/cpuidle: ux500: Rename driver symbol 2021-08-16 13:42:34 +01:00
cpuidle-zynq.c
cpuidle.c cpuidle: Select polling interval based on a c-state with a longer target residency 2020-12-01 17:59:18 +01:00
cpuidle.h
driver.c cpuidle: Avoid potential overflow in integer multiplication 2024-04-13 13:01:43 +02:00
dt_idle_states.c cpuidle: dt: Return the correct numbers of parsed idle states 2022-12-31 13:14:01 +01:00
dt_idle_states.h
governor.c
poll_state.c
sysfs.c cpuidle: Fix kobject memory leaks in error paths 2021-11-18 19:16:29 +01:00