Skip to content

Commit

Permalink
ACPI: CPPC: Add NULL pointer check to cppc_get_perf()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rafaeljw committed Nov 24, 2021
1 parent 1360572 commit 935dff3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/acpi/cppc_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,14 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
static int cppc_get_perf(int cpunum, enum cppc_regs reg_idx, u64 *perf)
{
struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum);
struct cpc_register_resource *reg = &cpc_desc->cpc_regs[reg_idx];
struct cpc_register_resource *reg;

if (!cpc_desc) {
pr_debug("No CPC descriptor for CPU:%d\n", cpunum);
return -ENODEV;
}

reg = &cpc_desc->cpc_regs[reg_idx];

if (CPC_IN_PCC(reg)) {
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpunum);
Expand Down

0 comments on commit 935dff3

Please sign in to comment.