Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp118241ybg; Mon, 8 Jun 2020 18:06:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySAbYnxMYIbQkg+VFdepIpl6TufJen35JopORdfonRWp78HhpvY0zR547iIM851YAEGnUB X-Received: by 2002:a17:906:57d3:: with SMTP id u19mr23879933ejr.401.1591664816061; Mon, 08 Jun 2020 18:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591664816; cv=none; d=google.com; s=arc-20160816; b=Sp3JrRaOUpt1YI4fqBkSTWchVKnNpRrRbOc63rjpaKCLA8+5mUHQP5OJ0piqgXCYxE JipoFnah+U8PgPKHFBWvDv9Q7KVnhlYZLYweO6ybaXSt60/LEHVzEDDlVd8uouXNRe3P I6O/KTj4puN9zOEf9lbm5AXVO0vUhKy2BqycK4nL3vPQ2MOiE9ib1i6NeZ5zXDwS0yI6 jNU9qc7TRqp2GZ+XpiA/HrB1T+7VOpiNQECmXJP5bvD6cZCkQ/qjlUU2tfe0XvNWeoA1 qhe88EcGGY4yU8PHeqLOPddJTvvGM0oPZ2SYefKpo8G1AL9yz66kH9PBbXyv/rdAN+tI wM9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YritakaFZAoyv4eVvIiWCu2ndSUF2r7AnehigQoe0sY=; b=qUQoAi8njSX/TWYCSzrSx3n49m3R1DuawrDh2CJTOUmT0tX5dhNvt8tNXsria8ukTP S4uO37/sj6RKztQGuXPyQftO1cr/aTpcKX3DEtaEoeXMM6eJ3mhLYZqtMtAWH1Hk52/I iQ7EgqZ0IZnqGBxImIqi1qtqjBnQC46tRhvhnuYFOZj2qhzy44/ym3AjAYE/zZ/jvmGV isyTblFpaHIwL079qT0CTXolFOd/EuWpRVkNVw1bDEvWhbFa2qnJxfxCviq6EH30oRfp /sdEtGHie7BDGAPgWARiJ7hIUY3RVFyaTSDGJhzMrc7o3NzVzSE04y0Xg+XylsIBfR/Q 9S9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vq3CXwS5; 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 n4si9852898eje.267.2020.06.08.18.06.33; Mon, 08 Jun 2020 18:06:56 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=vq3CXwS5; 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 S2388180AbgFIBEp (ORCPT + 99 others); Mon, 8 Jun 2020 21:04:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:51154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727866AbgFHXHW (ORCPT ); Mon, 8 Jun 2020 19:07:22 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 427F920888; Mon, 8 Jun 2020 23:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657642; bh=YE2oEMu6XyWmC2vXfQbvn/OXs6e+k5Ysv8EGha9IAKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vq3CXwS5riurYyniTn2wDL2g6iruKlXF/O1OrrnMMI8uYpXATpiUtjeAgFcO6UiNy M7fd0sJ+yx1nUKqaI00KSJvdpaCRCpeXbZumSdsVXZp0ufOROOgyWpipaCdI1DIASl xOk65YxxlQ7ir1q9nQpboSrPO3zMNb8iXqRuouZg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tuan Phan , Hanjun Guo , Lorenzo Pieralisi , Will Deacon , Sasha Levin , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.7 059/274] ACPI/IORT: Fix PMCG node single ID mapping handling Date: Mon, 8 Jun 2020 19:02:32 -0400 Message-Id: <20200608230607.3361041-59-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tuan Phan [ Upstream commit 50c8ab8d9fbf5b18d5162a797ca26568afc0af1a ] An IORT PMCG node can have no ID mapping if its overflow interrupt is wire based therefore the code that parses the PMCG node can not assume the node will always have a single mapping present at index 0. Fix iort_get_id_mapping_index() by checking for an overflow interrupt and mapping count. Fixes: 24e516049360 ("ACPI/IORT: Add support for PMCG") Signed-off-by: Tuan Phan Reviewed-by: Hanjun Guo Acked-by: Lorenzo Pieralisi Link: https://lore.kernel.org/r/1589994787-28637-1-git-send-email-tuanphan@os.amperecomputing.com Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- drivers/acpi/arm64/iort.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index 7d04424189df..ec04435a7cea 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -414,6 +414,7 @@ static struct acpi_iort_node *iort_node_get_id(struct acpi_iort_node *node, static int iort_get_id_mapping_index(struct acpi_iort_node *node) { struct acpi_iort_smmu_v3 *smmu; + struct acpi_iort_pmcg *pmcg; switch (node->type) { case ACPI_IORT_NODE_SMMU_V3: @@ -441,6 +442,10 @@ static int iort_get_id_mapping_index(struct acpi_iort_node *node) return smmu->id_mapping_index; case ACPI_IORT_NODE_PMCG: + pmcg = (struct acpi_iort_pmcg *)node->node_data; + if (pmcg->overflow_gsiv || node->mapping_count == 0) + return -EINVAL; + return 0; default: return -EINVAL; -- 2.25.1