[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240412103723.16943-1-amishin@t-argos.ru>
Date: Fri, 12 Apr 2024 13:37:23 +0300
From: Aleksandr Mishin <amishin@...rgos.ru>
To: Lv Zheng <lv.zheng@...el.com>
CC: Aleksandr Mishin <amishin@...rgos.ru>, Robert Moore
<robert.moore@...el.com>, "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
Len Brown <lenb@...nel.org>, <linux-acpi@...r.kernel.org>,
<acpica-devel@...ts.linux.dev>, <linux-kernel@...r.kernel.org>,
<lvc-project@...uxtesting.org>
Subject: [PATCH] ACPICA: Handle memory allocation error
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@...rgos.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
Powered by blists - more mailing lists