* [PATCH] PCI: of_property: Omit 'bus-range' property if no secondary bus
@ 2026-02-24 6:21 Bo Sun
2026-04-29 15:32 ` Manivannan Sadhasivam
0 siblings, 1 reply; 2+ messages in thread
From: Bo Sun @ 2026-02-24 6:21 UTC (permalink / raw)
To: linux-pci
Cc: Bo Sun, stable, Bjorn Helgaas, Bjorn Helgaas, Rob Herring,
Lizhi Hou, linux-kernel
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>
---
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 75a358f73e69..cade01ea6e68 100644
--- a/drivers/pci/of_property.c
+++ b/drivers/pci/of_property.c
@@ -95,6 +95,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 };
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] PCI: of_property: Omit 'bus-range' property if no secondary bus
2026-02-24 6:21 [PATCH] PCI: of_property: Omit 'bus-range' property if no secondary bus Bo Sun
@ 2026-04-29 15:32 ` Manivannan Sadhasivam
0 siblings, 0 replies; 2+ messages in thread
From: Manivannan Sadhasivam @ 2026-04-29 15:32 UTC (permalink / raw)
To: Bo Sun
Cc: linux-pci, stable, Bjorn Helgaas, Bjorn Helgaas, Rob Herring,
Lizhi Hou, linux-kernel
On Tue, Feb 24, 2026 at 02:21:03PM +0800, Bo Sun wrote:
> 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
Imperative tone, please.
> 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>
> ---
> 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 75a358f73e69..cade01ea6e68 100644
> --- a/drivers/pci/of_property.c
> +++ b/drivers/pci/of_property.c
> @@ -95,6 +95,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;
Returning errno is not 'omitting'. This will result in a failure of
of_pci_add_properties(). I hope that's not what you wanted.
- Mani
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-29 15:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-24 6:21 [PATCH] PCI: of_property: Omit 'bus-range' property if no secondary bus Bo Sun
2026-04-29 15:32 ` Manivannan Sadhasivam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®