Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3173947ybi; Fri, 5 Jul 2019 03:09:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyu/KJavImOtYng5TqQqhGla9zub7d31QUbBvVJHoQ93gvLyvxVJAsUm5a4CvvW+uvu2C/a X-Received: by 2002:a63:2b8e:: with SMTP id r136mr4460854pgr.216.1562321379380; Fri, 05 Jul 2019 03:09:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562321379; cv=none; d=google.com; s=arc-20160816; b=oa564LYckRhPmrSyvfTHA1UP+w/MCBCkwse7b/L19U/Y6ed7wK+B/Ml6CXF8LYlsnE 2jIiaAB6lwNzkPpUTGkHBJsDTuZ2No6qNLh5tUrSNCB5YFqsqMkEKE1fU+8ZaL2oOcnY T0uXNa8tAVqxjhZ9Z/f7g0YPgmeD8JSs0qrkzeEWHGpISVTOFSc7/Ce8iqJ2YeWoFXzV KVKIBCQUjVnG7q4usCaf2Ku/7XmgGOjUz1ohY4zKioBz/yuszKkG10Var+rflsmk+IXR b/2AKOu74bQVKdjgrU1ZEfmvOnhkar3X4/+i8S1c3AfjA4sFHHgyDUuGGbnozbUNJN8Q 8K3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=RJKev7oTCPvjiqRf0dpyj779IM1JpSi5dwL6vku4Zbs=; b=hx+tzH71rOz0SMbPXzyrtOMTWuzErPiYFMdchZmeRISfzGAQRETRHWBM523tRVAQHH vmyKxjYyotKP/dFYCRknLXRPheloMgGQUAbZKOzq5pabOYsE1zUQkluFU3T2Maq8RDUf pO66JQAXznaFDFhIvH7hsx85yfl7xQZyqUpZU4gp5lizhfA2yqRZbXwi1s1hpzgOFGTQ lb0VnIMAy9utxenw431VjGlif0N6qPHxfIR2N2CnptKt7U6vHJlvOSzjXtgFd+KJE5lC no3vuHJTW+Cn6bZBzKBwO9JsQcXGP0G5pUWQrv2Zw8BHJ+21xKhkD0QvDlGN5eUxW4df 5jMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a14si9126702pfo.37.2019.07.05.03.09.24; Fri, 05 Jul 2019 03:09:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728446AbfGEKHr (ORCPT + 99 others); Fri, 5 Jul 2019 06:07:47 -0400 Received: from inva021.nxp.com ([92.121.34.21]:48378 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728318AbfGEKHf (ORCPT ); Fri, 5 Jul 2019 06:07:35 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id B444D200044; Fri, 5 Jul 2019 12:07:33 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 35BAC2006F8; Fri, 5 Jul 2019 12:07:25 +0200 (CEST) Received: from titan.ap.freescale.net (TITAN.ap.freescale.net [10.192.208.233]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 7C75D4030E; Fri, 5 Jul 2019 18:07:14 +0800 (SGT) From: Hou Zhiqiang To: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, bhelgaas@google.com, robh+dt@kernel.org, mark.rutland@arm.com, l.subrahmanya@mobiveil.co.in, shawnguo@kernel.org, leoyang.li@nxp.com, lorenzo.pieralisi@arm.com, catalin.marinas@arm.com, will.deacon@arm.com Cc: Mingkai.Hu@nxp.com, Minghuan.Lian@nxp.com, Xiaowei.Bao@nxp.com, Hou Zhiqiang Subject: [PATCHv6 19/28] PCI: mobiveil: Fix the valid check for inbound and outbound window Date: Fri, 5 Jul 2019 17:56:47 +0800 Message-Id: <20190705095656.19191-20-Zhiqiang.Hou@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20190705095656.19191-1-Zhiqiang.Hou@nxp.com> References: <20190705095656.19191-1-Zhiqiang.Hou@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Check window index from the parameter instead of the total number of initialized windows to determine if the specified window is valid. Fixes: 9af6bcb11e12 ("PCI: mobiveil: Add Mobiveil PCIe Host Bridge IP driver") Signed-off-by: Hou Zhiqiang Reviewed-by: Minghuan Lian Reviewed-by: Subrahmanya Lingappa --- V6: - Splited from #9 of v5 patches, no functional change. drivers/pci/controller/pcie-mobiveil.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pcie-mobiveil.c b/drivers/pci/controller/pcie-mobiveil.c index ccf9bb1..76653d9 100644 --- a/drivers/pci/controller/pcie-mobiveil.c +++ b/drivers/pci/controller/pcie-mobiveil.c @@ -458,7 +458,7 @@ static void program_ib_windows(struct mobiveil_pcie *pcie, int win_num, u32 value; u64 size64 = ~(size - 1); - if ((pcie->ib_wins_configured + 1) > pcie->ppio_wins) { + if (win_num >= pcie->ppio_wins) { dev_err(&pcie->pdev->dev, "ERROR: max inbound windows reached !\n"); return; @@ -491,7 +491,7 @@ static void program_ob_windows(struct mobiveil_pcie *pcie, int win_num, { u64 size64 = ~(size - 1); - if ((pcie->ob_wins_configured + 1) > pcie->apio_wins) { + if (win_num >= pcie->apio_wins) { dev_err(&pcie->pdev->dev, "ERROR: max outbound windows reached !\n"); return; -- 1.7.1