Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3884422rwl; Mon, 10 Apr 2023 02:39:19 -0700 (PDT) X-Google-Smtp-Source: AKy350YNGSNCbnCVBe9sngw5DoVN2B74G4CKyUWRY6uG7bxzBUGarGCmG8Om8i+3RFkoHiu5oxRI X-Received: by 2002:a17:902:fb07:b0:1a5:2e19:bc40 with SMTP id le7-20020a170902fb0700b001a52e19bc40mr6383184plb.26.1681119559064; Mon, 10 Apr 2023 02:39:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681119559; cv=none; d=google.com; s=arc-20160816; b=Yuw8+TojZ3lqvWLbIr3D91G8AyF/NNA7x6qcKdKf3VETIoosVuCxv/fZajcd69osbx PbmOrP/DHar3SBJ7fU4M9wlvxWHd2zeM2EAENIP4DeOZaDmzIyBy8QFsRMmK/FipZG1q 1LJYaBhNX7mtjHTgAe9V383qsMbyNJo7EOf3zn2h6IcfHBaZXV9CAMpTyLUqrj33AuT8 cSx218aMlhTslemP+aC9iU+HStyed2LZ3WlpjHN9Hbbrs3Lb2nUeRqV66GiO7zk9H+2x /N5JjFiB01iSJr4f0zb3osGHQd4w92GFGLtYkHOI7z9sWh1SlTKbZw0g/lB0/DjDmvs0 BFdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ubUwFUOAqeVReislOkpAd/J3sb0ZDp89pdnm7SrP0Pc=; b=fm6MBc6BF/EhXl6g4lcmS0N/6OyODMNEuWmMXl+iSb2h4u85jO8doLlucBSXi/f6Na MIleFaerQSutehh2fBvEQn5czM+TSHgp1Uxir0kYFdlGRah6tg7chj2FB427vfpiVefb 62tXR21FcmKUw2X/7oB5YWG6hII6wo1uDJgWjYTfuqCEmvZ/J1OG3nbipP0sF4cEnkhp Gsuu3lzE4CkoUnO3+6UHvfkeBqbVjsblYEMlqNlzGEcuN4ilAqN/lbWomYCE6nyZ4Ncg FircrGOiJJrrr5+SmwUL5tU10rs9abKgicf/mYAa2PXAf/vcibr918Rg2O82kUNgZ4nF 9qRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j10-20020a63230a000000b0050beec91e30si10161991pgj.768.2023.04.10.02.39.06; Mon, 10 Apr 2023 02:39:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229718AbjDJJhV (ORCPT + 99 others); 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 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: void0red@hust.edu.cn X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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, -- 2.34.1