ACPI: platform_profile: Avoid initializing on non-ACPI platforms
authorAlexandre Ghiti <alexghiti@rivosinc.com>
Thu, 22 May 2025 14:13:56 +0000 (16:13 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 23 May 2025 14:44:52 +0000 (16:44 +0200)
The platform profile driver is loaded even on platforms that do not have
ACPI enabled. The initialization of the sysfs entries was recently moved
from platform_profile_register() to the module init call, and those
entries need acpi_kobj to be initialized which is not the case when ACPI
is disabled.

This results in the following warning:

 WARNING: CPU: 5 PID: 1 at fs/sysfs/group.c:131 internal_create_group+0xa22/0xdd8
 Modules linked in:
 CPU: 5 UID: 0 PID: 1 Comm: swapper/0 Tainted: G        W           6.15.0-rc7-dirty #6 PREEMPT
 Tainted: [W]=WARN
 Hardware name: riscv-virtio,qemu (DT)
 epc : internal_create_group+0xa22/0xdd8
  ra : internal_create_group+0xa22/0xdd8

 Call Trace:

 internal_create_group+0xa22/0xdd8
 sysfs_create_group+0x22/0x2e
 platform_profile_init+0x74/0xb2
 do_one_initcall+0x198/0xa9e
 kernel_init_freeable+0x6d8/0x780
 kernel_init+0x28/0x24c
 ret_from_fork+0xe/0x18

Fix this by checking if ACPI is enabled before trying to create sysfs
entries.

Fixes: 77be5cacb2c2 ("ACPI: platform_profile: Create class for ACPI platform profile")
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Link: https://patch.msgid.link/20250522141410.31315-1-alexghiti@rivosinc.com
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/platform_profile.c

index ffbfd32f4cf1ba8337c8c0bdca800b3f5895be5d..b43f4459a4f61e67e27a2564712118134bf447f6 100644 (file)
@@ -688,6 +688,9 @@ static int __init platform_profile_init(void)
 {
        int err;
 
+       if (acpi_disabled)
+               return -EOPNOTSUPP;
+
        err = class_register(&platform_profile_class);
        if (err)
                return err;