提交 721f9208 编写于 作者: D Daniil Tatianin 提交者: Yongqiang Liu

ACPICA: nsrepair: handle cases without a return value correctly

stable inclusion
from stable-v4.19.276
commit 331db828d34c37c466e4915fd50ea51415da143c
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6TIG1
CVE: NA

--------------------------------

[ Upstream commit ca843a4c ]

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: 61db45ca ("ACPICA: Restore code that repairs NULL package elements in return values.")
Signed-off-by: NDaniil Tatianin <d-tatianin@yandex-team.ru>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 09f78ae4
...@@ -181,8 +181,9 @@ acpi_ns_simple_repair(struct acpi_evaluate_info *info, ...@@ -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. * Try to fix if there was no return object. Warning if failed to fix.
*/ */
if (!return_object) { if (!return_object) {
if (expected_btypes && (!(expected_btypes & ACPI_RTYPE_NONE))) { if (expected_btypes) {
if (package_index != ACPI_NOT_PACKAGE_ELEMENT) { if (!(expected_btypes & ACPI_RTYPE_NONE) &&
package_index != ACPI_NOT_PACKAGE_ELEMENT) {
ACPI_WARN_PREDEFINED((AE_INFO, ACPI_WARN_PREDEFINED((AE_INFO,
info->full_pathname, info->full_pathname,
ACPI_WARN_ALWAYS, ACPI_WARN_ALWAYS,
...@@ -196,16 +197,17 @@ acpi_ns_simple_repair(struct acpi_evaluate_info *info, ...@@ -196,16 +197,17 @@ acpi_ns_simple_repair(struct acpi_evaluate_info *info,
if (ACPI_SUCCESS(status)) { if (ACPI_SUCCESS(status)) {
return (AE_OK); /* Repair was successful */ return (AE_OK); /* Repair was successful */
} }
} else { }
if (expected_btypes != ACPI_RTYPE_NONE) {
ACPI_WARN_PREDEFINED((AE_INFO, ACPI_WARN_PREDEFINED((AE_INFO,
info->full_pathname, info->full_pathname,
ACPI_WARN_ALWAYS, ACPI_WARN_ALWAYS,
"Missing expected return value")); "Missing expected return value"));
}
return (AE_AML_NO_RETURN_VALUE); return (AE_AML_NO_RETURN_VALUE);
} }
} }
}
if (expected_btypes & ACPI_RTYPE_INTEGER) { if (expected_btypes & ACPI_RTYPE_INTEGER) {
status = acpi_ns_convert_to_integer(return_object, &new_object); status = acpi_ns_convert_to_integer(return_object, &new_object);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册