From patchwork Thu Nov 25 12:45:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 12693649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B90F3C4332F for ; Thu, 25 Nov 2021 12:48:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rXjZIxYw/fXMTw/gwPUDTYZXxNe0/3+LF2/5AYnjmpw=; b=yzi3YMac+TAc3X Dqf+OnUbgGXbFPkDyuyRnMD7NGlvec0m1tTmLUnJPzAfC9B/kqDYxWhkmaisIVh7/KPXgR5nbEhM7 y7ujx2LUGfAWHEUMZMgvq/y4SQS7NQD58rLROcvFX1Y7mPFMIFZmZvWc/nYPS0yTX70h4mav5DJgl otjY7EN03hNww+OtJNhbVtAspeKCuDDiVArN1qOoyJhFMvszaXgSCqtia4A9mqdfVlggKxA46cfp6 +qwJA+XyvqWO9TpMJHnYcBV3anaFKA+9hP9s/CWyHiAHMVri6Vv97FzTwAAeyomhBSLJxjscqcqxX yBqTG/o+yMG+u0AAbgCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqE9F-007SqQ-0r; Thu, 25 Nov 2021 12:46:45 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqE94-007SnN-By for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 12:46:37 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id BBDA4610A7; Thu, 25 Nov 2021 12:46:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1637844393; bh=tPbNDMR/pO/XPt3w0yjPE5vVD9ywEbzQpey0qyJc5AU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S0DpSVTPYHPRgHrA99G17xbggKeFyLVfMnuzn8kj+rNnt5CWQALQNFFKWceLwK58c Gb83wxr+S8X1Ar5xy+KtkQ8hdsFB0az0BVvvl8zKebrj62fc+BUDJeXuJCK19mYDit SVkTxTg8N1WLOdt5knnj8v06L9kfvRKF1U3hirwZzyTP/zT3o9q7gQRWgJ2Or8Ypw5 bZly5veqkkyW+5PC1I4EWp7GQ37dWuVhJZ2+YVFAkGPRBhPIFQhbi1hQWm/GNcz5mD 9AAn9FXnEBARTxUkcczGc0LUXFt39imW0/DT+BSsl70/2Ue2s7HMv0QpXyJ8JaZkYk jdAgiB8YK4Hpw== Received: by pali.im (Postfix) id 01C47EDE; Thu, 25 Nov 2021 13:46:30 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Thomas Petazzoni , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/15] PCI: mvebu: Check for valid ports Date: Thu, 25 Nov 2021 13:45:51 +0100 Message-Id: <20211125124605.25915-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211125124605.25915-1-pali@kernel.org> References: <20211125124605.25915-1-pali@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211125_044634_504305_F1CC6C72 X-CRM114-Status: GOOD ( 12.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some mvebu ports do not have to be initialized. So skip these uninitialized mvebu ports in every port iteration function to prevent access to unmapped memory or dereferencing NULL pointers. Uninitialized mvebu port has base address set to NULL. Signed-off-by: Pali Rohár Cc: stable@vger.kernel.org --- drivers/pci/controller/pci-mvebu.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c index 06f06085beba..d655c887ba1b 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -625,6 +625,9 @@ static struct mvebu_pcie_port *mvebu_pcie_find_port(struct mvebu_pcie *pcie, for (i = 0; i < pcie->nports; i++) { struct mvebu_pcie_port *port = &pcie->ports[i]; + if (!port->base) + continue; + if (bus->number == 0 && port->devfn == devfn) return port; if (bus->number != 0 && @@ -800,6 +803,8 @@ static int mvebu_pcie_suspend(struct device *dev) pcie = dev_get_drvdata(dev); for (i = 0; i < pcie->nports; i++) { struct mvebu_pcie_port *port = pcie->ports + i; + if (!port->base) + continue; port->saved_pcie_stat = mvebu_readl(port, PCIE_STAT_OFF); } @@ -814,6 +819,8 @@ static int mvebu_pcie_resume(struct device *dev) pcie = dev_get_drvdata(dev); for (i = 0; i < pcie->nports; i++) { struct mvebu_pcie_port *port = pcie->ports + i; + if (!port->base) + continue; mvebu_writel(port, port->saved_pcie_stat, PCIE_STAT_OFF); mvebu_pcie_setup_hw(port); }