From: Bo Sun <Bo.Sun.CN@windriver.com>
To: Bjorn Helgaas <bhelgaas@google.com>,
Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: Vidya Sagar <vidyas@nvidia.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Kevin Hao <kexin.hao@windriver.com>
Subject: [PATCH v3 2/2] PCI: of_property: Omit 'bus-range' property if no secondary bus
Date: Mon, 24 Mar 2025 17:01:08 +0800 [thread overview]
Message-ID: <20250324090108.965229-3-Bo.Sun.CN@windriver.com> (raw)
In-Reply-To: <20250324090108.965229-1-Bo.Sun.CN@windriver.com>
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.
Cc: stable@vger.kernel.org
Fixes: 407d1a51921e ("PCI: Create device tree node for bridge")
Suggested-by: Bjorn Helgaas <helgaas@kernel.org>
Signed-off-by: Bo Sun <Bo.Sun.CN@windriver.com>
---
v3: Add 'Fixes' tag as requested by Mani.
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.49.0
next prev parent reply other threads:[~2025-03-24 9:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-24 9:01 [PATCH v3 0/2] PCI: Marvell CN96XX/CN10XXX quirk and bus-range omission Bo Sun
2025-03-24 9:01 ` [PATCH v3 1/2] PCI: Forcefully set the PCI_REASSIGN_ALL_BUS flag for Marvell CN96XX/CN10XXX boards Bo Sun
2025-03-27 16:37 ` Manivannan Sadhasivam
2025-05-19 10:04 ` Bo Sun
2025-03-24 9:01 ` Bo Sun [this message]
2025-03-27 16:37 ` [PATCH v3 2/2] PCI: of_property: Omit 'bus-range' property if no secondary bus Manivannan Sadhasivam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250324090108.965229-3-Bo.Sun.CN@windriver.com \
--to=bo.sun.cn@windriver.com \
--cc=bhelgaas@google.com \
--cc=kexin.hao@windriver.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=vidyas@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox