Skip to content

Commit 62f969d

Browse files
committed
powercap: dtpm_cpu: Fix NULL pointer dereference in get_pd_power_uw()
JIRA: https://issues.redhat.com/browse/RHEL-110835 commit 46dc574 Author: Sivan Zohar-Kotzer <sivany32@gmail.com> Date: Wed Jul 2 01:13:55 2025 +0300 powercap: dtpm_cpu: Fix NULL pointer dereference in get_pd_power_uw() 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: eb82bac ("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: Steve Best <sbest@redhat.com>
1 parent d583a28 commit 62f969d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/powercap/dtpm_cpu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ static u64 get_pd_power_uw(struct dtpm *dtpm)
9696
int i;
9797

9898
pd = em_cpu_get(dtpm_cpu->cpu);
99+
if (!pd)
100+
return 0;
99101

100102
pd_mask = em_span_cpus(pd);
101103

0 commit comments

Comments
 (0)