From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from huawei.com (huawei.com [45.249.212.32]) by mx.groups.io with SMTP id smtpd.web12.1248.1582621448113450415 for ; Tue, 25 Feb 2020 01:04:08 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: huawei.com, ip: 45.249.212.32, mailfrom: guoheyi@huawei.com) 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: "Guoheyi" 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 X-Originating-IP: [10.175.104.212] X-CFilter-Loop: Reflected Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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(struc= t acpi_iort_node *node, map =3D ACPI_ADD_PTR(struct acpi_iort_id_mapping, node, node->mapping_offset); =20 - /* 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(struc= t acpi_iort_node *node, if (i =3D=3D node->mapping_count) goto fail_map; =20 + /* 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 =3D ACPI_ADD_PTR(struct acpi_iort_node, iort_table, map->output_reference); } --=20 2.19.1