From patchwork Mon Apr 10 09:36:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kang Chen X-Patchwork-Id: 672054 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 59CB3C77B61 for ; Mon, 10 Apr 2023 09:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229535AbjDJJhV (ORCPT ); Mon, 10 Apr 2023 05:37:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjDJJhU (ORCPT ); Mon, 10 Apr 2023 05:37:20 -0400 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1955430E2; Mon, 10 Apr 2023 02:37:18 -0700 (PDT) Received: from passwd123-ThinkStation-P920.. ([222.20.94.23]) (user=void0red@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 33A9a3KL017631-33A9a3KM017631 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 10 Apr 2023 17:36:03 +0800 From: Kang Chen To: rafael@kernel.org Cc: acpica-devel@lists.linuxfoundation.org, lenb@kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, rafael.j.wysocki@intel.com, robert.moore@intel.com, void0red@gmail.com Subject: [PATCH v2] ACPICA: check null return of ACPI_ALLOCATE_ZEROED in acpi_db_display_objects Date: Mon, 10 Apr 2023 17:36:01 +0800 Message-Id: <20230410093601.3945712-1-void0red@hust.edu.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-FEAS-AUTH-USER: void0red@hust.edu.cn Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Kang Chen ACPI_ALLOCATE_ZEROED may fails, object_info might be null and will cause null pointer dereference later. Link: https://github.com/acpica/acpica/commit/84b3752cfa0ce4b0ebecae5e193c937b8ed6e278 Signed-off-by: Kang Chen --- v2 -> v1: add a github link drivers/acpi/acpica/dbnames.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/acpi/acpica/dbnames.c b/drivers/acpi/acpica/dbnames.c index 3615e1a6e..b91155ea9 100644 --- a/drivers/acpi/acpica/dbnames.c +++ b/drivers/acpi/acpica/dbnames.c @@ -652,6 +652,9 @@ acpi_status acpi_db_display_objects(char *obj_type_arg, char *display_count_arg) object_info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_object_info)); + if (!object_info) + return (AE_NO_MEMORY); + /* Walk the namespace from the root */ (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,