Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp721742pxb; Fri, 14 Jan 2022 15:01:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzgdXIpRLTW0G5nO180kx4IzJV2FWyfXjP01yaT1WNRGA/o+ddpxz5K9Mtiqhsd/IkFJUbR X-Received: by 2002:a62:503:0:b0:4bc:764c:5524 with SMTP id 3-20020a620503000000b004bc764c5524mr10972016pff.25.1642201271095; Fri, 14 Jan 2022 15:01:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642201271; cv=none; d=google.com; s=arc-20160816; b=KSJOsMfMBSU2DcnypTJZReVOGRTsPb7yvXVVObLAyeLwn8X2RESIYP/O4Czerl/qkj LZ7hmcPKmouJvqH+pL/iv/y2XiFXIO7MrF6sbRqrOAGMr9m6i9BVMdxdS6EhHiXBdY4S yramGJp6dWzrNRZOTtD0jGyfjmHNjQ2UmkTElBehZJWdoc4ABFMrsax9OTSaHlV22FF9 794E+mZXfVLZ4ZXP6LyEoYZ8W49vnZ4o/HNKJLwkrsNajHO6785+QQ//HCZa4NMUccsd Y2wwTM49eb/t6O4ryt1dAUJAzi1fCHuXHqTR7Pg6ZJYj2lOZiuo/VGTP8kqjiNDvd6yA r+qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=vWFRqt1snG0vKk4A5HswSbVNh90av8m781UEgmU/+DA=; b=w+1nZYHYN5S/1xOzwKIsM1kamoVAEgnmHgXWmlQYnfmnZLcAhu9Y/Ry/GHugKPl46Y XWsKZxXlZP3TFJFEdmO6cXvqxF4AAadg8q/Oypau23tirGuj4BXxK45SHQjST4SsDfqq aTwIB+QnEmvJROGH2vGKzX1rPFG0ctWJThTP+6fHdORzPc0yNsEQ0Cd2/6uq5hl958BS xao04qUvQNPXqw1nkldhfkKesvTTANGrE0NF31IBCvfB+CZIUKvrY+lqT9Pf4k+uFeOA cx1iF3JBwGNry+DSuq5zhUOqtGwY3QSI+qNXtkExXNQy7nlkpPbmAIgva7+fKNsNcNTw EGZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q12si7534453pgv.555.2022.01.14.15.00.59; Fri, 14 Jan 2022 15:01:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243996AbiANSJb (ORCPT + 99 others); Fri, 14 Jan 2022 13:09:31 -0500 Received: from mail-qt1-f174.google.com ([209.85.160.174]:38857 "EHLO mail-qt1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235405AbiANSJa (ORCPT ); Fri, 14 Jan 2022 13:09:30 -0500 Received: by mail-qt1-f174.google.com with SMTP id bb9so6035407qtb.5; Fri, 14 Jan 2022 10:09:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vWFRqt1snG0vKk4A5HswSbVNh90av8m781UEgmU/+DA=; b=11KrcIlSxri4kn5ralE0W0fEdSHvTSkjo9NcwZ8ksO0/f6VyVgxGz2JHds4PdYX3Kb 5wzjpLm5D4NL/qaB7YQuYUNe4aOi7u8OcIlNKtw4Z1o7oArc+OIYIc/V9v5qD8vzLE77 LU9tCQK/KGrzavyT2YaxBSpAa/LLTQkhC1MA11dXVi5njdRij2sw91QIlYdVnwHbXWYu BC5Me686GO5XGYY4hLrVIgso7M78zumoZDOG5fl40UZEBM+WOBCAarTHEnmchiYqHod+ kf9Uvx96wEtQce5eRNhLw9w2+M8xiW+c0W+rrpV3dXkspsJDsbOwx7hSKynu0VSbb/A5 v9HQ== X-Gm-Message-State: AOAM532Rg5uKhvTqLcudKNvkKoQY9Gyyj56knbcX0H9E4CwzxmXd3e7a gceg3HFK6UX8vZPH0K4tUAe07XOPcSjPwhpjnAw= X-Received: by 2002:a05:622a:1881:: with SMTP id v1mr8653852qtc.327.1642183769801; Fri, 14 Jan 2022 10:09:29 -0800 (PST) MIME-Version: 1.0 References: <20220114101546.1368163-1-jiasheng@iscas.ac.cn> In-Reply-To: <20220114101546.1368163-1-jiasheng@iscas.ac.cn> From: "Rafael J. Wysocki" Date: Fri, 14 Jan 2022 19:09:18 +0100 Message-ID: Subject: Re: [PATCH] ACPI/ACPICA: Check for NULL pointer after calling alloc To: Jiasheng Jiang Cc: Robert Moore , Rafael Wysocki , Len Brown , ACPI Devel Maling List , "open list:ACPI COMPONENT ARCHITECTURE (ACPICA)" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 14, 2022 at 11:16 AM Jiasheng Jiang wrote: > > As the possible failure of the allocation, object_info could be NULL > pointer. > Therefore, it should be better to check it in order to avoid the > dereference of the NULL pointer. > If fails, we should return 'AE_NON_MEMORY' and the caller > acpi_db_command_dispatch() will deal with the return status of > acpi_db_display_objects(). > Also, the comment of the acpi_db_display_objects() is wrong. > So we need to correct it too. > > Fixes: 995751025572 ("ACPICA: Linuxize: Export debugger files to Linux") > Signed-off-by: Jiasheng Jiang This is ACPICA material, so it needs to be submitted to the upstream ACPICA project via https://github.com/acpica/acpica, thanks! > --- > drivers/acpi/acpica/dbnames.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/acpi/acpica/dbnames.c b/drivers/acpi/acpica/dbnames.c > index 3615e1a6efd8..d8e5852fadb1 100644 > --- a/drivers/acpi/acpica/dbnames.c > +++ b/drivers/acpi/acpica/dbnames.c > @@ -632,7 +632,7 @@ acpi_db_walk_for_specific_objects(acpi_handle obj_handle, > * PARAMETERS: obj_type_arg - Type of object to display > * display_count_arg - Max depth to display > * > - * RETURN: None > + * RETURN: Status > * > * DESCRIPTION: Display objects in the namespace of the requested type > * > @@ -651,6 +651,8 @@ acpi_status acpi_db_display_objects(char *obj_type_arg, char *display_count_arg) > if (!obj_type_arg) { > object_info = > ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_object_info)); > + if (!object_info) > + return (AE_NO_MEMORY); > > /* Walk the namespace from the root */ > > -- > 2.25.1 >