* [PATCH] PCI: Check parent for NULL in of_pci_bus_release_domain_nr()
@ 2026-01-27 20:39 Sergey Shtylyov
2026-01-28 19:34 ` Sergey Shtylyov
2026-01-29 18:31 ` Bjorn Helgaas
0 siblings, 2 replies; 3+ messages in thread
From: Sergey Shtylyov @ 2026-01-27 20:39 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci; +Cc: Sergey Shtylyov, Pali Rohár
of_pci_bus_find_domain_nr() allows its parent parameter to be NULL but
of_pci_bus_release_domain_nr() (that undoes its effect) doesn't -- that
means it's going to blow up while calling of_get_pci_domain_nr() if the
parent parameter indeed happens to be NULL. Add the missing NULL check.
Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.
Fixes: c14f7ccc9f5d ("PCI: Assign PCI domain IDs by ida_alloc()")
Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev>
---
drivers/pci/pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 13dbb405dc31..9fc4c2226b03 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -6591,7 +6591,7 @@ static void of_pci_bus_release_domain_nr(struct device *parent, int domain_nr)
return;
/* Release domain from IDA where it was allocated. */
- if (of_get_pci_domain_nr(parent->of_node) == domain_nr)
+ if (parent && of_get_pci_domain_nr(parent->of_node) == domain_nr)
ida_free(&pci_domain_nr_static_ida, domain_nr);
else
ida_free(&pci_domain_nr_dynamic_ida, domain_nr);
--
2.52.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI: Check parent for NULL in of_pci_bus_release_domain_nr()
2026-01-27 20:39 [PATCH] PCI: Check parent for NULL in of_pci_bus_release_domain_nr() Sergey Shtylyov
@ 2026-01-28 19:34 ` Sergey Shtylyov
2026-01-29 18:31 ` Bjorn Helgaas
1 sibling, 0 replies; 3+ messages in thread
From: Sergey Shtylyov @ 2026-01-28 19:34 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci; +Cc: Pali Rohár
On 1/27/26 11:39 PM, Sergey Shtylyov wrote:
> of_pci_bus_find_domain_nr() allows its parent parameter to be NULL but
> of_pci_bus_release_domain_nr() (that undoes its effect) doesn't -- that
> means it's going to blow up while calling of_get_pci_domain_nr() if the
> parent parameter indeed happens to be NULL. Add the missing NULL check.
>
> Found by Linux Verification Center (linuxtesting.org) with the Svace static
> analysis tool.
>
> Fixes: c14f7ccc9f5d ("PCI: Assign PCI domain IDs by ida_alloc()")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev>
> ---
Forgot to add that this patch was done against the for-linus branch of
the pci.git repo...
[...]
MBR, Sergey
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI: Check parent for NULL in of_pci_bus_release_domain_nr()
2026-01-27 20:39 [PATCH] PCI: Check parent for NULL in of_pci_bus_release_domain_nr() Sergey Shtylyov
2026-01-28 19:34 ` Sergey Shtylyov
@ 2026-01-29 18:31 ` Bjorn Helgaas
1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2026-01-29 18:31 UTC (permalink / raw)
To: Sergey Shtylyov; +Cc: Bjorn Helgaas, linux-pci, Pali Rohár
On Tue, Jan 27, 2026 at 11:39:42PM +0300, Sergey Shtylyov wrote:
> of_pci_bus_find_domain_nr() allows its parent parameter to be NULL but
> of_pci_bus_release_domain_nr() (that undoes its effect) doesn't -- that
> means it's going to blow up while calling of_get_pci_domain_nr() if the
> parent parameter indeed happens to be NULL. Add the missing NULL check.
>
> Found by Linux Verification Center (linuxtesting.org) with the Svace static
> analysis tool.
>
> Fixes: c14f7ccc9f5d ("PCI: Assign PCI domain IDs by ida_alloc()")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev>
Applied to pci/enumeration for v6.20, thanks!
> ---
> drivers/pci/pci.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 13dbb405dc31..9fc4c2226b03 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -6591,7 +6591,7 @@ static void of_pci_bus_release_domain_nr(struct device *parent, int domain_nr)
> return;
>
> /* Release domain from IDA where it was allocated. */
> - if (of_get_pci_domain_nr(parent->of_node) == domain_nr)
> + if (parent && of_get_pci_domain_nr(parent->of_node) == domain_nr)
> ida_free(&pci_domain_nr_static_ida, domain_nr);
> else
> ida_free(&pci_domain_nr_dynamic_ida, domain_nr);
> --
> 2.52.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-29 18:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-27 20:39 [PATCH] PCI: Check parent for NULL in of_pci_bus_release_domain_nr() Sergey Shtylyov
2026-01-28 19:34 ` Sergey Shtylyov
2026-01-29 18:31 ` Bjorn Helgaas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox