From patchwork Wed Jul 26 04:52:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwamu Okabe X-Patchwork-Id: 13327493 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD427C001DC for ; Wed, 26 Jul 2023 04:59:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231392AbjGZE70 (ORCPT ); Wed, 26 Jul 2023 00:59:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230505AbjGZE7X (ORCPT ); Wed, 26 Jul 2023 00:59:23 -0400 X-Greylist: delayed 383 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 25 Jul 2023 21:59:22 PDT Received: from mail.valinux.co.jp (mail.valinux.co.jp [210.128.90.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AC9C1BD1; Tue, 25 Jul 2023 21:59:22 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail.valinux.co.jp (Postfix) with ESMTP id C0A3EA9283; Wed, 26 Jul 2023 13:52:58 +0900 (JST) X-Virus-Scanned: Debian amavisd-new at valinux.co.jp Received: from mail.valinux.co.jp ([127.0.0.1]) by localhost (mail.valinux.co.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wPaDkWnveZzF; Wed, 26 Jul 2023 13:52:58 +0900 (JST) Received: from [172.16.3.34] (vagw.valinux.co.jp [210.128.90.14]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by mail.valinux.co.jp (Postfix) with ESMTPSA id A5BDCA8FA7; Wed, 26 Jul 2023 13:52:58 +0900 (JST) Message-ID: <9445401f-7cfb-bbb5-e25c-28f578efa212@valinux.co.jp> Date: Wed, 26 Jul 2023 13:52:58 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Content-Language: en-US To: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org From: Kiwamu Okabe Subject: [PATCH] ACPI: tables: Fix NULL dereference by acpi_os_map_memory() Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The Infer static analyzer https://fbinfer.com/ reports following NULL poinster dereference by the acpi_os_map_memory() function. I believe this patch does fix the issue without any panic. Signed-off-by: Kiwamu Okabe --- drivers/acpi/tables.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 8ab0a82b4da4..ae7b7343bacf 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -717,6 +717,9 @@ acpi_table_initrd_override(struct acpi_table_header *existing_table, while (table_offset + ACPI_HEADER_SIZE <= all_tables_size) { table = acpi_os_map_memory(acpi_tables_addr + table_offset, ACPI_HEADER_SIZE); + if (WARN_ON(!table)) { + return AE_OK; + } if (table_offset + table->length > all_tables_size) { acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); WARN_ON(1); @@ -772,6 +775,9 @@ static void __init acpi_table_initrd_scan(void) while (table_offset + ACPI_HEADER_SIZE <= all_tables_size) { table = acpi_os_map_memory(acpi_tables_addr + table_offset, ACPI_HEADER_SIZE); + if (WARN_ON(!table)) { + return; + } if (table_offset + table->length > all_tables_size) { acpi_os_unmap_memory(table, ACPI_HEADER_SIZE); WARN_ON(1);