diff mbox series

ACPICA: Handle memory allocation error

Message ID 20240412103723.16943-1-amishin@t-argos.ru
State New
Headers show
Series ACPICA: Handle memory allocation error | expand

Commit Message

Aleksandr Mishin April 12, 2024, 10:37 a.m. UTC
In acpi_db_add_to_history() acpi_os_allocate() may return NULL
in case of memory allocation error. This will lead to NULL pointer
dereference.
Fix this bug by adding NULL return check.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 995751025572 ("ACPICA: Linuxize: Export debugger files to Linux")
Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
---
 drivers/acpi/acpica/dbhistry.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/drivers/acpi/acpica/dbhistry.c b/drivers/acpi/acpica/dbhistry.c
index e874c1dddefa..8366631d457f 100644
--- a/drivers/acpi/acpica/dbhistry.c
+++ b/drivers/acpi/acpica/dbhistry.c
@@ -69,6 +69,8 @@  void acpi_db_add_to_history(char *command_line)
 		acpi_gbl_history_buffer[acpi_gbl_next_history_index].command =
 		    acpi_os_allocate(cmd_len + 1);
 	}
+	if (!acpi_gbl_history_buffer[acpi_gbl_next_history_index].command)
+		return;
 
 	strcpy(acpi_gbl_history_buffer[acpi_gbl_next_history_index].command,
 	       command_line);