linux-stable/drivers/cpuidle
C Cheng 35b5f8e99a 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:09:58 +02:00
..
governors cpuidle: teo: Avoid unnecessary variable assignments 2023-08-23 18:25:04 +02:00
Kconfig
Kconfig.arm
Kconfig.mips
Kconfig.powerpc
Kconfig.riscv
Makefile
coupled.c
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: haltpoll: Do not enable interrupts when entering idle 2023-12-29 18:08:18 +01:00
cpuidle-kirkwood.c
cpuidle-mvebu-v7.c
cpuidle-powernv.c
cpuidle-psci-domain.c cpuidle: psci: Move enabling OSI mode after power domains creation 2023-08-08 16:07:01 +02:00
cpuidle-psci.c cpuidle: Adjust includes to remove of_device.h 2023-04-13 17:46:35 -05:00
cpuidle-psci.h
cpuidle-pseries.c powerpc/pseries: Rework lppaca_shared_proc() to avoid DEBUG_PREEMPT 2023-08-24 22:33:17 +10:00
cpuidle-qcom-spm.c cpuidle: Adjust includes to remove of_device.h 2023-04-13 17:46:35 -05:00
cpuidle-riscv-sbi.c RISC-V: Align SBI probe implementation with spec 2023-04-29 13:04:50 -07:00
cpuidle-tegra.c
cpuidle-ux500.c
cpuidle-zynq.c
cpuidle.c cpuidle: Use local_clock_noinstr() 2023-06-05 21:11:09 +02:00
cpuidle.h cpuidle: move to use bus_get_dev_root() 2023-03-22 20:25:23 +01:00
driver.c cpuidle: Avoid potential overflow in integer multiplication 2024-04-13 13:09:58 +02:00
dt_idle_genpd.c cpuidle: dt_idle_genpd: Add helper function to remove genpd topology 2023-08-08 16:06:20 +02:00
dt_idle_genpd.h cpuidle: dt_idle_genpd: Add helper function to remove genpd topology 2023-08-08 16:06:20 +02:00
dt_idle_states.c cpuidle: dt: Replace deprecated strncpy() with strscpy() 2023-09-29 14:48:31 -07:00
dt_idle_states.h
governor.c
poll_state.c cpuidle: Use local_clock_noinstr() 2023-06-05 21:11:09 +02:00
sysfs.c cpuidle: move to use bus_get_dev_root() 2023-03-22 20:25:23 +01:00