Skip to content

Commit ca843a4

Browse files
d-tatianinrafaeljw
authored andcommitted
ACPICA: nsrepair: handle cases without a return value correctly
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: acpica/acpica#811 Fixes: 61db45c ("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]>
1 parent 91fdb91 commit ca843a4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/acpi/acpica/nsrepair.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@ acpi_ns_simple_repair(struct acpi_evaluate_info *info,
181181
* Try to fix if there was no return object. Warning if failed to fix.
182182
*/
183183
if (!return_object) {
184-
if (expected_btypes && (!(expected_btypes & ACPI_RTYPE_NONE))) {
185-
if (package_index != ACPI_NOT_PACKAGE_ELEMENT) {
184+
if (expected_btypes) {
185+
if (!(expected_btypes & ACPI_RTYPE_NONE) &&
186+
package_index != ACPI_NOT_PACKAGE_ELEMENT) {
186187
ACPI_WARN_PREDEFINED((AE_INFO,
187188
info->full_pathname,
188189
ACPI_WARN_ALWAYS,
@@ -196,14 +197,15 @@ acpi_ns_simple_repair(struct acpi_evaluate_info *info,
196197
if (ACPI_SUCCESS(status)) {
197198
return (AE_OK); /* Repair was successful */
198199
}
199-
} else {
200+
}
201+
202+
if (expected_btypes != ACPI_RTYPE_NONE) {
200203
ACPI_WARN_PREDEFINED((AE_INFO,
201204
info->full_pathname,
202205
ACPI_WARN_ALWAYS,
203206
"Missing expected return value"));
207+
return (AE_AML_NO_RETURN_VALUE);
204208
}
205-
206-
return (AE_AML_NO_RETURN_VALUE);
207209
}
208210
}
209211

0 commit comments

Comments
 (0)