[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250311135229.3329381-3-Bo.Sun.CN@windriver.com>
Date: Tue, 11 Mar 2025 21:52:29 +0800
From: Bo Sun <Bo.Sun.CN@...driver.com>
To: Bjorn Helgaas <bhelgaas@...gle.com>
Cc: Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>,
Vidya Sagar <vidyas@...dia.com>, linux-pci@...r.kernel.org,
linux-kernel@...r.kernel.org, Kevin Hao <kexin.hao@...driver.com>,
Bo Sun <Bo.Sun.CN@...driver.com>, Bjorn Helgaas <helgaas@...nel.org>
Subject: [PATCH v2 2/2] PCI: of_property: Omit 'bus-range' property if no secondary bus
The previous implementation of of_pci_add_properties() and
of_pci_prop_bus_range() assumed that a valid secondary bus is always
present, which can be problematic in cases where no bus numbers are
assigned for a secondary bus. This patch introduces a check for a valid
secondary bus and omits the 'bus-range' property if it is not available,
preventing dereferencing the NULL pointer.
Suggested-by: Bjorn Helgaas <helgaas@...nel.org>
Signed-off-by: Bo Sun <Bo.Sun.CN@...driver.com>
---
v2: New patch.
drivers/pci/of_property.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c
index 58fbafac7c6a..792b0163af45 100644
--- a/drivers/pci/of_property.c
+++ b/drivers/pci/of_property.c
@@ -91,6 +91,9 @@ static int of_pci_prop_bus_range(struct pci_dev *pdev,
struct of_changeset *ocs,
struct device_node *np)
{
+ if (!pdev->subordinate)
+ return -EINVAL;
+
u32 bus_range[] = { pdev->subordinate->busn_res.start,
pdev->subordinate->busn_res.end };
--
2.48.1
Powered by blists - more mailing lists