Skip to contentSkip to conversation

ACPI: bus: Remove the not needed NULL set

PATCH Applied Hanjun Guo 2 participants 3 messages Jun 2, 2021 – Jun 7, 2021 ACPI

lore
Share & tools
lore

Hanjun Guo

author
#0 lore raw

PATCH 1/2 ACPI: bus: Remove the not needed NULL set

Code running with if (!acpi_kobj) is true, acpi_kobj is NULL as it is, no need to set to NULL.

---
 drivers/acpi/bus.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/acpi/bus.c +1 -3
index 60787d9..f9b5262 100644
@@ -1325,10 +1325,8 @@ static int __init acpi_init(void)
 	}
 
 	acpi_kobj = kobject_create_and_add("acpi", firmware_kobj);
-	if (!acpi_kobj) {
+	if (!acpi_kobj)
 		pr_debug("%s: kset create error\n", __func__);
-		acpi_kobj = NULL;
-	}
 
 	result = acpi_bus_init();
 	if (result) {
Signature · 1 line
1.7.12.4
author
#1 lore raw

PATCH 2/2 ACPI: bus: Call kobject_put() in error path for acpi_init()

Although the system will not in good condition or boot failed if acpi_bus_init() failed, we still need to put the kobject in error patch before return, to make the code right.

---
 drivers/acpi/bus.c | 1 +
 1 file changed, 1 insertion(+)
drivers/acpi/bus.c +1 -0
index f9b5262..008ae29 100644
@@ -1330,6 +1330,7 @@ static int __init acpi_init(void)
 
 	result = acpi_bus_init();
 	if (result) {
+		kobject_put(acpi_kobj);
 		disable_acpi();
 		return result;
 	}
Signature · 1 line
1.7.12.4
maintainer Applied
#2 lore raw
In reply to Hanjun Guo
Quoted 16 lines · Hanjun Guo

Code running with if (!acpi_kobj) is true, acpi_kobj is NULL as it is, no need to set to NULL.

---
 drivers/acpi/bus.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/acpi/bus.c +0 -0
index 60787d9..f9b5262 100644
@@ -1325,10 +1325,8 @@ static int __init acpi_init(void)
        }
 

drivers/acpi/bus.c static int __init acpi_init(void)

Quoted 10 lines
drivers/acpi/bus.c +1 -4
        acpi_kobj = kobject_create_and_add("acpi", firmware_kobj);
-       if (!acpi_kobj) {
+       if (!acpi_kobj)
                pr_debug("%s: kset create error\n", __func__);
-               acpi_kobj = NULL;
-       }
 
        result = acpi_bus_init();
        if (result) {
--

Applied as 5.14 material along with the [2/2[ with some edits in the subject and changelog, thanks!