lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Mon, 13 May 2024 17:49:00 +0200
From: Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>
To: lpieralisi@...nel.org,
	kw@...ux.com,
	bhelgaas@...gle.com
Cc: robh@...nel.org,
	thierry.reding@...il.com,
	jonathanh@...dia.com,
	vidyas@...dia.com,
	linux-pci@...r.kernel.org,
	linux-tegra@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>,
	kernel test robot <lkp@...el.com>
Subject: [PATCH] PCI: tegra194: Add check for host and endpoint modes

Tegra194 driver supports both the host and endpoint mode, but there are no
checks to validate whether the corresponding mode is enabled in kernel
config or not. So if the driver tries to function without enabling the
required mode (CONFIG_PCIE_TEGRA194_HOST/CONFIG_PCIE_TEGRA194_EP), then it
will result in driver malfunction.

So let's add the checks in probe() before doing the mode specific config
and fail probe() if the corresponding mode is not enabled.

But this also requires adding one redundant check in
pex_ep_event_pex_rst_assert() for pci_epc_deinit_notify(). Because the
function is called outside of probe() and the compiler fails to spot the
dependency in probe() and still complains about the undefined reference to
pci_epc_deinit_notify().

Reported-by: kernel test robot <lkp@...el.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202405130815.BwBrIepL-lkp@intel.com
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>
---
 drivers/pci/controller/dwc/pcie-tegra194.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c
index d2223821e122..e02a9bca70ef 100644
--- a/drivers/pci/controller/dwc/pcie-tegra194.c
+++ b/drivers/pci/controller/dwc/pcie-tegra194.c
@@ -1715,7 +1715,16 @@ static void pex_ep_event_pex_rst_assert(struct tegra_pcie_dw *pcie)
 	if (ret)
 		dev_err(pcie->dev, "Failed to go Detect state: %d\n", ret);
 
-	pci_epc_deinit_notify(pcie->pci.ep.epc);
+	/*
+	 * We do not really need the below guard as the driver won't probe
+	 * successfully if it tries to probe in EP mode and
+	 * CONFIG_PCIE_TEGRA194_EP is not enabled. But since this function is
+	 * being called outside of probe(), compiler fails to spot the
+	 * dependency in probe() and hence this redundant check.
+	 */
+	if (IS_ENABLED(CONFIG_PCIE_TEGRA194_EP))
+		pci_epc_deinit_notify(pcie->pci.ep.epc);
+
 	dw_pcie_ep_cleanup(&pcie->pci.ep);
 
 	reset_control_assert(pcie->core_rst);
@@ -2245,6 +2254,11 @@ static int tegra_pcie_dw_probe(struct platform_device *pdev)
 
 	switch (pcie->of_data->mode) {
 	case DW_PCIE_RC_TYPE:
+		if (!IS_ENABLED(CONFIG_PCIE_TEGRA194_HOST)) {
+			ret = -ENODEV;
+			goto fail;
+		}
+
 		ret = devm_request_irq(dev, pp->irq, tegra_pcie_rp_irq_handler,
 				       IRQF_SHARED, "tegra-pcie-intr", pcie);
 		if (ret) {
@@ -2261,6 +2275,11 @@ static int tegra_pcie_dw_probe(struct platform_device *pdev)
 		break;
 
 	case DW_PCIE_EP_TYPE:
+		if (!IS_ENABLED(CONFIG_PCIE_TEGRA194_EP)) {
+			ret = -ENODEV;
+			goto fail;
+		}
+
 		ret = devm_request_threaded_irq(dev, pp->irq,
 						tegra_pcie_ep_hard_irq,
 						tegra_pcie_ep_irq_thread,
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ