Skip to content

Commit 935dff3

Browse files
committed
ACPI: CPPC: Add NULL pointer check to cppc_get_perf()
Check cpc_desc against NULL in cppc_get_perf(), so it doesn't crash down the road if cpc_desc is NULL. Fixes: 0654cf0 ("ACPI: CPPC: Introduce cppc_get_nominal_perf()") Reported-by: Kai-Heng Feng <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]> Cc: 5.15+ <[email protected]> # 5.15+ Tested-by: Kai-Heng Feng <[email protected]>
1 parent 1360572 commit 935dff3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/acpi/cppc_acpi.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,14 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
998998
static int cppc_get_perf(int cpunum, enum cppc_regs reg_idx, u64 *perf)
999999
{
10001000
struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum);
1001-
struct cpc_register_resource *reg = &cpc_desc->cpc_regs[reg_idx];
1001+
struct cpc_register_resource *reg;
1002+
1003+
if (!cpc_desc) {
1004+
pr_debug("No CPC descriptor for CPU:%d\n", cpunum);
1005+
return -ENODEV;
1006+
}
1007+
1008+
reg = &cpc_desc->cpc_regs[reg_idx];
10021009

10031010
if (CPC_IN_PCC(reg)) {
10041011
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum);

0 commit comments

Comments
 (0)