linux/drivers/powercap
Sivan Zohar-Kotzer 8374ac7d69 powercap: dtpm_cpu: Fix NULL pointer dereference in get_pd_power_uw()
[ Upstream commit 46dc574068 ]

The get_pd_power_uw() function can crash with a NULL pointer dereference
when em_cpu_get() returns NULL. This occurs when a CPU becomes impossible
during runtime, causing get_cpu_device() to return NULL, which propagates
through em_cpu_get() and leads to a crash when em_span_cpus() dereferences
the NULL pointer.

Add a NULL check after em_cpu_get() and return 0 if unavailable,
matching the existing fallback behavior in __dtpm_cpu_setup().

Fixes: eb82bace89 ("powercap/drivers/dtpm: Scale the power with the load")
Signed-off-by: Sivan Zohar-Kotzer <sivany32@gmail.com>
Link: https://patch.msgid.link/20250701221355.96916-1-sivany32@gmail.com
[ rjw: Drop an excess empty code line ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-08-15 12:13:36 +02:00
..
arm_scmi_powercap.c powercap: arm_scmi: Remove recursion while parsing zones 2023-07-20 20:27:10 +02:00
dtpm.c powercap: dtpm: Fix kernel-doc for dtpm_create_hierarchy() function 2024-03-01 21:39:10 +01:00
dtpm_cpu.c powercap: dtpm_cpu: Fix NULL pointer dereference in get_pd_power_uw() 2025-08-15 12:13:36 +02:00
dtpm_devfreq.c powercap: dtpm_devfreq: Fix error check against dev_pm_qos_add_request() 2024-10-21 13:23:06 +02:00
dtpm_subsys.h powercap/drivers/dtpm: Add dtpm devfreq with energy model support 2022-02-04 17:38:09 +01:00
idle_inject.c powercap: idle_inject: Simplify if condition 2024-06-07 20:57:20 +02:00
intel_rapl_common.c powercap: intel_rapl: Do not change CLAMPING bit if ENABLE bit cannot be changed 2025-07-10 16:05:12 +02:00
intel_rapl_msr.c powercap: intel_rapl_msr: Add PL4 support for ArrowLake-H 2024-10-16 22:34:03 +02:00
intel_rapl_tpmi.c powercap: intel_rapl_tpmi: Ignore minor version change 2024-10-08 21:38:49 +02:00
Kconfig powercap: RAPL: Fix CONFIG_IOSF_MBI dependency 2023-06-12 19:48:40 +02:00
Makefile powercap: intel_rapl: Introduce RAPL TPMI interface driver 2023-05-24 18:46:20 +02:00
powercap_sys.c powercap: call put_device() on an error path in powercap_register_control_type() 2025-03-22 12:54:14 -07:00