Skip to content

Commit 6a3cc1b

Browse files
committed
Merge tag 'acpi-6.18-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI fixes from Rafael Wysocki: "These fix issues in the ACPI CPPC library and in the recently added parser for the ACPI MRRM table: - Limit some checks in the ACPI CPPC library to online CPUs to avoid accessing uninitialized per-CPU variables when some CPUs are offline to start with, like during boot with 'nosmt=force' (Gautham Shenoy) - Rework add_boot_memory_ranges() in the ACPI MRRM table parser to fix memory leaks and improve error handling (Kaushlendra Kumar)" * tag 'acpi-6.18-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: ACPI: MRRM: Fix memory leaks and improve error handling ACPI: CPPC: Limit perf ctrs in PCC check only to online CPUs ACPI: CPPC: Perform fast check switch only for online CPUs ACPI: CPPC: Check _CPC validity for only the online CPUs ACPI: CPPC: Detect preferred core availability on online CPUs
2 parents 9b9e437 + 7564f35 commit 6a3cc1b

3 files changed

Lines changed: 37 additions & 14 deletions

File tree

arch/x86/kernel/acpi/cppc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ int amd_detect_prefcore(bool *detected)
196196
break;
197197
}
198198

199-
for_each_present_cpu(cpu) {
199+
for_each_online_cpu(cpu) {
200200
u32 tmp;
201201
int ret;
202202

drivers/acpi/acpi_mrrm.c

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,26 +152,49 @@ ATTRIBUTE_GROUPS(memory_range);
152152

153153
static __init int add_boot_memory_ranges(void)
154154
{
155-
struct kobject *pkobj, *kobj;
155+
struct kobject *pkobj, *kobj, **kobjs;
156156
int ret = -EINVAL;
157-
char *name;
157+
char name[16];
158+
int i;
158159

159160
pkobj = kobject_create_and_add("memory_ranges", acpi_kobj);
161+
if (!pkobj)
162+
return -ENOMEM;
160163

161-
for (int i = 0; i < mrrm_mem_entry_num; i++) {
162-
name = kasprintf(GFP_KERNEL, "range%d", i);
163-
if (!name) {
164-
ret = -ENOMEM;
165-
break;
166-
}
164+
kobjs = kcalloc(mrrm_mem_entry_num, sizeof(*kobjs), GFP_KERNEL);
165+
if (!kobjs) {
166+
kobject_put(pkobj);
167+
return -ENOMEM;
168+
}
167169

170+
for (i = 0; i < mrrm_mem_entry_num; i++) {
171+
scnprintf(name, sizeof(name), "range%d", i);
168172
kobj = kobject_create_and_add(name, pkobj);
173+
if (!kobj) {
174+
ret = -ENOMEM;
175+
goto cleanup;
176+
}
169177

170178
ret = sysfs_create_groups(kobj, memory_range_groups);
171-
if (ret)
172-
return ret;
179+
if (ret) {
180+
kobject_put(kobj);
181+
goto cleanup;
182+
}
183+
kobjs[i] = kobj;
173184
}
174185

186+
kfree(kobjs);
187+
return 0;
188+
189+
cleanup:
190+
for (int j = 0; j < i; j++) {
191+
if (kobjs[j]) {
192+
sysfs_remove_groups(kobjs[j], memory_range_groups);
193+
kobject_put(kobjs[j]);
194+
}
195+
}
196+
kfree(kobjs);
197+
kobject_put(pkobj);
175198
return ret;
176199
}
177200

drivers/acpi/cppc_acpi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ bool acpi_cpc_valid(void)
460460
if (acpi_disabled)
461461
return false;
462462

463-
for_each_present_cpu(cpu) {
463+
for_each_online_cpu(cpu) {
464464
cpc_ptr = per_cpu(cpc_desc_ptr, cpu);
465465
if (!cpc_ptr)
466466
return false;
@@ -476,7 +476,7 @@ bool cppc_allow_fast_switch(void)
476476
struct cpc_desc *cpc_ptr;
477477
int cpu;
478478

479-
for_each_present_cpu(cpu) {
479+
for_each_online_cpu(cpu) {
480480
cpc_ptr = per_cpu(cpc_desc_ptr, cpu);
481481
desired_reg = &cpc_ptr->cpc_regs[DESIRED_PERF];
482482
if (!CPC_IN_SYSTEM_MEMORY(desired_reg) &&
@@ -1435,7 +1435,7 @@ bool cppc_perf_ctrs_in_pcc(void)
14351435
{
14361436
int cpu;
14371437

1438-
for_each_present_cpu(cpu) {
1438+
for_each_online_cpu(cpu) {
14391439
struct cpc_register_resource *ref_perf_reg;
14401440
struct cpc_desc *cpc_desc;
14411441

0 commit comments

Comments
 (0)