Commit c6ec2709 authored by Sivan Zohar-Kotzer's avatar Sivan Zohar-Kotzer Committed by Greg Kroah-Hartman
Browse files

powercap: dtpm_cpu: Fix NULL pointer dereference in get_pd_power_uw()



[ Upstream commit 46dc5740 ]

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: eb82bace ("powercap/drivers/dtpm: Scale the power with the load")
Signed-off-by: default avatarSivan 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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 91a177aa
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment