summaryrefslogtreecommitdiff
path: root/kernel/debug/debug_core.c
diff options
context:
space:
mode:
authorZhongqiu Han <zhongqiu.han@oss.qualcomm.com>2026-11-10 21:58:14 +0800
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2026-11-10 19:52:27 +0100
commitc5bdb87573726d3a10c58bb3ae09daf017be2297 (patch)
treea700b9d7d39cb3c9061066acc7375766f2b2f11c /kernel/debug/debug_core.c
parent7cca01c39cc89f6ef39079484d26b6d99287a610 (diff)
cpufreq: Skip inactive policies in cpufreq_driver_target()
A policy obtained with cpufreq_cpu_get() may become inactive before cpufreq_driver_target() acquires its rwsem, which may lead to a NULL pointer dereference: CPU X CPU Y (last CPU in policy) cpufreq_cpu_get() cpufreq_offline() __cpufreq_offline() ->exit() /* frees freq_table */ policy->freq_table = NULL cpufreq_driver_target() __cpufreq_driver_target() __target_index() policy->freq_table[index] /* NULL dereference */ Before commit 2372784542cb ("cpufreq: Drop 'freq_table' argument of __target_index()"), __cpufreq_driver_target() returned an error if policy->freq_table was NULL. Since the offline path clears it under the policy rwsem, which cpufreq_driver_target() also holds, that check was sufficient to prevent the crash. The race has been reachable in-tree since commit c210063b40ac ("cpufreq: mediatek: Add opp notification support"), which added the first caller of cpufreq_driver_target() that can run concurrently with CPU offline. Address this by making cpufreq_driver_target() return -EBUSY if the policy is inactive after acquiring its rwsem, in analogy with the checks in cpufreq_get(), refresh_frequency_limits() and the sysfs show() and store() callbacks. Reported-by: Sashiko <sashiko-bot@kernel.org> Closes: https://sashiko.dev/#/patchset/20261104153042.3987338-1-zhongqiu.han%40oss.qualcomm.com Fixes: 2372784542cb ("cpufreq: Drop 'freq_table' argument of __target_index()") Fixes: c210063b40ac ("cpufreq: mediatek: Add opp notification support") Cc: 5.19+ <stable@vger.kernel.org> # v5.19+ Signed-off-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com> Link: https://patch.msgid.link/20261110135814.621355-1-zhongqiu.han@oss.qualcomm.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'kernel/debug/debug_core.c')
0 files changed, 0 insertions, 0 deletions