diff mbox series

[2/2] ACPI: bus: Bail out if acpi_kobj registration fails

Message ID 20250518185111.3560-2-W_Armin@gmx.de
State Accepted
Commit 94a370fc8def6038dbc02199db9584b0b3690f1a
Headers show
Series [1/2] ACPI: platform_profile: Add support for non-ACPI platforms | expand

Commit Message

Armin Wolf May 18, 2025, 6:51 p.m. UTC
The ACPI sysfs code will fail to initialize if acpi_kobj is NULL,
together with some ACPI drivers. Follow the other firmware subsystems
and bail out if the kobject cannot be registered.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/acpi/bus.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Rafael J. Wysocki May 23, 2025, 2:56 p.m. UTC | #1
On Sun, May 18, 2025 at 8:51 PM Armin Wolf <W_Armin@gmx.de> wrote:
>
> The ACPI sysfs code will fail to initialize if acpi_kobj is NULL,
> together with some ACPI drivers. Follow the other firmware subsystems
> and bail out if the kobject cannot be registered.
>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
>  drivers/acpi/bus.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index 058910af82bc..c2ab2783303f 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -1446,8 +1446,10 @@ static int __init acpi_init(void)
>         }
>
>         acpi_kobj = kobject_create_and_add("acpi", firmware_kobj);
> -       if (!acpi_kobj)
> -               pr_debug("%s: kset create error\n", __func__);
> +       if (!acpi_kobj) {
> +               pr_err("Failed to register kobject\n");
> +               return -ENOMEM;
> +       }
>
>         init_prmt();
>         acpi_init_pcc();
> --

Applied as 6.16 material, thanks!
diff mbox series

Patch

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 058910af82bc..c2ab2783303f 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -1446,8 +1446,10 @@  static int __init acpi_init(void)
 	}
 
 	acpi_kobj = kobject_create_and_add("acpi", firmware_kobj);
-	if (!acpi_kobj)
-		pr_debug("%s: kset create error\n", __func__);
+	if (!acpi_kobj) {
+		pr_err("Failed to register kobject\n");
+		return -ENOMEM;
+	}
 
 	init_prmt();
 	acpi_init_pcc();