]> Git Repo - linux.git/commitdiff
ACPICA: nsrepair: handle cases without a return value correctly
authorDaniil Tatianin <[email protected]>
Fri, 6 Jan 2023 23:53:08 +0000 (02:53 +0300)
committerRafael J. Wysocki <[email protected]>
Tue, 10 Jan 2023 19:19:05 +0000 (20:19 +0100)
Previously acpi_ns_simple_repair() would crash if expected_btypes
contained any combination of ACPI_RTYPE_NONE with a different type,
e.g | ACPI_RTYPE_INTEGER because of slightly incorrect logic in the
!return_object branch, which wouldn't return AE_AML_NO_RETURN_VALUE
for such cases.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Link: https://github.com/acpica/acpica/pull/811
Fixes: 61db45ca2163 ("ACPICA: Restore code that repairs NULL package elements in return values.")
Signed-off-by: Daniil Tatianin <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
drivers/acpi/acpica/nsrepair.c

index 367fcd201f96e3e2d193b86f4b7e9624dc7dcd83..ec512e06a48edea81ab9c56f2f98a8975a3cbda5 100644 (file)
@@ -181,8 +181,9 @@ acpi_ns_simple_repair(struct acpi_evaluate_info *info,
         * Try to fix if there was no return object. Warning if failed to fix.
         */
        if (!return_object) {
-               if (expected_btypes && (!(expected_btypes & ACPI_RTYPE_NONE))) {
-                       if (package_index != ACPI_NOT_PACKAGE_ELEMENT) {
+               if (expected_btypes) {
+                       if (!(expected_btypes & ACPI_RTYPE_NONE) &&
+                           package_index != ACPI_NOT_PACKAGE_ELEMENT) {
                                ACPI_WARN_PREDEFINED((AE_INFO,
                                                      info->full_pathname,
                                                      ACPI_WARN_ALWAYS,
@@ -196,14 +197,15 @@ acpi_ns_simple_repair(struct acpi_evaluate_info *info,
                                if (ACPI_SUCCESS(status)) {
                                        return (AE_OK); /* Repair was successful */
                                }
-                       } else {
+                       }
+
+                       if (expected_btypes != ACPI_RTYPE_NONE) {
                                ACPI_WARN_PREDEFINED((AE_INFO,
                                                      info->full_pathname,
                                                      ACPI_WARN_ALWAYS,
                                                      "Missing expected return value"));
+                               return (AE_AML_NO_RETURN_VALUE);
                        }
-
-                       return (AE_AML_NO_RETURN_VALUE);
                }
        }
 
This page took 0.05922 seconds and 4 git commands to generate.