Skip to contentSkip to conversation

ACPI: APEI: ERST: Fix missing error code in erst_init()

PATCH In review Jiapeng Chong 3 participants 3 messages Jun 1, 2021 – Jun 2, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: APEI: ERST: Fix missing error code in erst_init()

The error code is missing in this code scenario, add the error code '-EINVAL' to the return value 'rc'.

Eliminate the follow smatch warning:

drivers/acpi/apei/erst.c:1114 erst_init() warn: missing error code 'rc'.

---
 drivers/acpi/apei/erst.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/acpi/apei/erst.c +3 -2
index 242f3c2..492d499 100644
@@ -1110,9 +1110,10 @@ static int __init erst_init(void)
 
 	status = acpi_get_table(ACPI_SIG_ERST, 0,
 				(struct acpi_table_header **)&erst_tab);
-	if (status == AE_NOT_FOUND)
+	if (status == AE_NOT_FOUND) {
+		rc = -EINVAL;
 		goto err;
-	else if (ACPI_FAILURE(status)) {
+	} else if (ACPI_FAILURE(status)) {
 		const char *msg = acpi_format_exception(status);
 		pr_err("Failed to get table, %s\n", msg);
 		rc = -EINVAL;
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 9 lines · Jiapeng Chong

The error code is missing in this code scenario, add the error code '-EINVAL' to the return value 'rc'.

Eliminate the follow smatch warning:

drivers/acpi/apei/erst.c:1114 erst_init() warn: missing error code 'rc'.

Is this a bug? I can't tell if this is meant to be a "silent" failure, like with acpi_disabled, erst_disabled, etc.

If it _is_ a bug, then please include:

Fixes a08f82d08053 ("ACPI, APEI, Error Record Serialization Table (ERST) support")

-Kees

Quoted 24 lines
---
 drivers/acpi/apei/erst.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/acpi/apei/erst.c +3 -2
index 242f3c2..492d499 100644
@@ -1110,9 +1110,10 @@ static int __init erst_init(void)
 
 	status = acpi_get_table(ACPI_SIG_ERST, 0,
 				(struct acpi_table_header **)&erst_tab);
-	if (status == AE_NOT_FOUND)
+	if (status == AE_NOT_FOUND) {
+		rc = -EINVAL;
 		goto err;
-	else if (ACPI_FAILURE(status)) {
+	} else if (ACPI_FAILURE(status)) {
 		const char *msg = acpi_format_exception(status);
 		pr_err("Failed to get table, %s\n", msg);
 		rc = -EINVAL;
Signature · 1 line
1.8.3.1
Signature · 1 line
Kees Cook
#2 lore raw
Quoted 30 lines · Kees Cook
Quoted 9 lines · Jiapeng Chong

The error code is missing in this code scenario, add the error code '-EINVAL' to the return value 'rc'.

Eliminate the follow smatch warning:

drivers/acpi/apei/erst.c:1114 erst_init() warn: missing error code 'rc'.

Is this a bug? I can't tell if this is meant to be a "silent" failure, like with acpi_disabled, erst_disabled, etc.

If it _is_ a bug, then please include:

Fixes a08f82d08053 ("ACPI, APEI, Error Record Serialization Table (ERST) support")

-Kees

Quoted 10 lines
---
 drivers/acpi/apei/erst.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/acpi/apei/erst.c +0 -0
index 242f3c2..492d499 100644
@@ -1110,9 +1110,10 @@ static int __init erst_init(void)
 
Quoted 5 lines

drivers/acpi/apei/erst.c static int __init erst_init(void) · line 1114

Quoted 5 lines
drivers/acpi/apei/erst.c +2 -1
 	status = acpi_get_table(ACPI_SIG_ERST, 0,
 				(struct acpi_table_header **)&erst_tab);
-	if (status == AE_NOT_FOUND)
+	if (status == AE_NOT_FOUND) {
+		rc = -EINVAL;

I don't think this is necessary. It isn't an error not to have ERST table in a machine.

Best Regards,
Huang, Ying

Quoted 9 lines
Quoted 9 lines
drivers/acpi/apei/erst.c +1 -1
 		goto err;
-	else if (ACPI_FAILURE(status)) {
+	} else if (ACPI_FAILURE(status)) {
 		const char *msg = acpi_format_exception(status);
 		pr_err("Failed to get table, %s\n", msg);
 		rc = -EINVAL;
Signature · 1 line
1.8.3.1