diff mbox series

ACPI:dbconvert:check null return of ACPI_ALLOCATE_ZEROED in acpi_db_convert_to_package

Message ID tencent_ADB80DA880207BBCFA4F5CE7F05CDD221409@qq.com (mailing list archive)
State Superseded, archived
Headers show
Series ACPI:dbconvert:check null return of ACPI_ALLOCATE_ZEROED in acpi_db_convert_to_package | expand

Commit Message

xiaopeitux@foxmail.com July 31, 2024, 1:14 a.m. UTC
From: Pei Xiao <xiaopei01@kylinos.cn>

ACPI_ALLOCATE_ZEROED may fails, elements might be null and will cause
null pointer dereference later.

Link: https://github.com/acpica/acpica/commit/4d4547cf
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
 drivers/acpi/acpica/dbconvert.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/drivers/acpi/acpica/dbconvert.c b/drivers/acpi/acpica/dbconvert.c
index 2b84ac093698..a60d1098a105 100644
--- a/drivers/acpi/acpica/dbconvert.c
+++ b/drivers/acpi/acpica/dbconvert.c
@@ -175,6 +175,8 @@  acpi_status acpi_db_convert_to_package(char *string, union acpi_object *object)
 	    ACPI_ALLOCATE_ZEROED(DB_DEFAULT_PKG_ELEMENTS *
 				 sizeof(union acpi_object));
 
+	if (!elements)
+		return (AE_NO_MEMORY);
 	this = string;
 	for (i = 0; i < (DB_DEFAULT_PKG_ELEMENTS - 1); i++) {
 		this = acpi_db_get_next_token(this, &next, &type);