Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDE9EC35DF5 for ; Tue, 25 Feb 2020 09:04:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F85E21927 for ; Tue, 25 Feb 2020 09:04:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729416AbgBYJEI (ORCPT ); Tue, 25 Feb 2020 04:04:08 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:41422 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729153AbgBYJEI (ORCPT ); Tue, 25 Feb 2020 04:04:08 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 6F6B2544FE40937246FC; Tue, 25 Feb 2020 17:04:04 +0800 (CST) Received: from linux-TFkxOR.huawei.com (10.175.104.212) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Tue, 25 Feb 2020 17:03:46 +0800 From: Heyi Guo To: CC: , Heyi Guo , "Lorenzo Pieralisi" , Hanjun Guo , Sudeep Holla , "Rafael J. Wysocki" , Len Brown , , , Subject: [PATCH] acpi/iort: check output reference for the real used mapping Date: Tue, 25 Feb 2020 17:01:36 +0800 Message-ID: <20200225090136.40989-1-guoheyi@huawei.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.212] X-CFilter-Loop: Reflected Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The function iort_node_map_id() does the sanity check against the first mapping in the node, but not the one which we really use. Logically we need check the mapping we use, or check every mapping in the node. Choose the first fix for we are not firmware tester. Signed-off-by: Heyi Guo --- Cc: Lorenzo Pieralisi Cc: Hanjun Guo Cc: Sudeep Holla Cc: "Rafael J. Wysocki" Cc: Len Brown Cc: linux-acpi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/acpi/arm64/iort.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index ed3d2d1a7ae9..d0fe8d673240 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -470,13 +470,6 @@ static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node, map = ACPI_ADD_PTR(struct acpi_iort_id_mapping, node, node->mapping_offset); - /* Firmware bug! */ - if (!map->output_reference) { - pr_err(FW_BUG "[node %p type %d] ID map has NULL parent reference\n", - node, node->type); - goto fail_map; - } - /* * Get the special ID mapping index (if any) and skip its * associated ID map to prevent erroneous multi-stage @@ -497,6 +490,13 @@ static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node, if (i == node->mapping_count) goto fail_map; + /* Firmware bug! */ + if (!map->output_reference) { + pr_err(FW_BUG "[node %p type %d] ID map has NULL parent reference\n", + node, node->type); + goto fail_map; + } + node = ACPI_ADD_PTR(struct acpi_iort_node, iort_table, map->output_reference); } -- 2.19.1