]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
powercap: intel_rapl: Fix a NULL pointer dereference
authorZhang Rui <rui.zhang@intel.com>
Wed, 31 Jan 2024 11:37:08 +0000 (19:37 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Apr 2024 13:28:18 +0000 (15:28 +0200)
commit0641908b906a133f1494c312a71f9fecbe2b6c78
tree5124247fdd41e8c0cc557be4aac8a8b1278a9eb0
parent9df6a7a3c951e5745480b659db2389dee5bf41f6
powercap: intel_rapl: Fix a NULL pointer dereference

[ Upstream commit 2d1f5006ff95770da502f8cee2a224a1ff83866e ]

A NULL pointer dereference is triggered when probing the MMIO RAPL
driver on platforms with CPU ID not listed in intel_rapl_common CPU
model list.

This is because the intel_rapl_common module still probes on such
platforms even if 'defaults_msr' is not set after commit 1488ac990ac8
("powercap: intel_rapl: Allow probing without CPUID match"). Thus the
MMIO RAPL rp->priv->defaults is NULL when registering to RAPL framework.

Fix the problem by adding sanity check to ensure rp->priv->rapl_defaults
is always valid.

Fixes: 1488ac990ac8 ("powercap: intel_rapl: Allow probing without CPUID match")
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Cc: 6.5+ <stable@vger.kernel.org> # 6.5+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/powercap/intel_rapl_common.c