From 7c0f007cf589ac01e35d555d0c8d98f4a72396d4 Mon Sep 17 00:00:00 2001 From: Ronak Kanabar Date: Mon, 30 Nov 2020 15:40:51 +0530 Subject: [PATCH] src/acpi/acpigen: Add NULL pointer check Add NULL pointer check in acpigen_emit_namestring to avoid segmentation fault. Change-Id: I3d01d28e74f202278b5a5a96d2edd45c66f10883 Signed-off-by: Ronak Kanabar Reviewed-on: https://review.coreboot.org/c/coreboot/+/48148 Reviewed-by: Subrata Banik Reviewed-by: Maulik V Vaghela Tested-by: build bot (Jenkins) --- src/acpi/acpigen.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c index 244ac548c9..9a5543d5a4 100644 --- a/src/acpi/acpigen.c +++ b/src/acpi/acpigen.c @@ -291,6 +291,10 @@ void acpigen_emit_namestring(const char *namepath) int dotcount = 0, i; int dotpos = 0; + /* Check for NULL pointer */ + if (!namepath) + return; + /* We can start with a '\'. */ if (namepath[0] == '\\') { acpigen_emit_byte('\\');