[PATCH] ACPI/ACPICA: Check for NULL pointer after calling alloc
From: Jiasheng Jiang
Date: Fri Jan 14 2022 - 05:16:17 EST
As the possible failure of the allocation, object_info could be NULL
pointer.
Therefore, it should be better to check it in order to avoid the
dereference of the NULL pointer.
If fails, we should return 'AE_NON_MEMORY' and the caller
acpi_db_command_dispatch() will deal with the return status of
acpi_db_display_objects().
Also, the comment of the acpi_db_display_objects() is wrong.
So we need to correct it too.
Fixes: 995751025572 ("ACPICA: Linuxize: Export debugger files to Linux")
Signed-off-by: Jiasheng Jiang <jiasheng@xxxxxxxxxxx>
---
drivers/acpi/acpica/dbnames.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/acpica/dbnames.c b/drivers/acpi/acpica/dbnames.c
index 3615e1a6efd8..d8e5852fadb1 100644
--- a/drivers/acpi/acpica/dbnames.c
+++ b/drivers/acpi/acpica/dbnames.c
@@ -632,7 +632,7 @@ acpi_db_walk_for_specific_objects(acpi_handle obj_handle,
* PARAMETERS: obj_type_arg - Type of object to display
* display_count_arg - Max depth to display
*
- * RETURN: None
+ * RETURN: Status
*
* DESCRIPTION: Display objects in the namespace of the requested type
*
@@ -651,6 +651,8 @@ acpi_status acpi_db_display_objects(char *obj_type_arg, char *display_count_arg)
if (!obj_type_arg) {
object_info =
ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_object_info));
+ if (!object_info)
+ return (AE_NO_MEMORY);
/* Walk the namespace from the root */
--
2.25.1