Linux-ACPI Archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPICA: Handle memory allocation error
@ 2024-04-12 10:37 Aleksandr Mishin
  0 siblings, 0 replies; only message in thread
From: Aleksandr Mishin @ 2024-04-12 10:37 UTC (permalink / raw
  To: Lv Zheng
  Cc: Aleksandr Mishin, Robert Moore, Rafael J. Wysocki, Len Brown,
	linux-acpi, acpica-devel, linux-kernel, lvc-project

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 --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);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-12 10:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-12 10:37 [PATCH] ACPICA: Handle memory allocation error Aleksandr Mishin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).