]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI: Check parent for NULL in of_pci_bus_release_domain_nr()
authorSergey Shtylyov <s.shtylyov@auroraos.dev>
Tue, 27 Jan 2026 20:39:42 +0000 (23:39 +0300)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 29 Jan 2026 18:29:20 +0000 (12:29 -0600)
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>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20260127203944.28588-1-s.shtylyov@auroraos.dev
drivers/pci/pci.c

index 13dbb405dc31f8054afa090a2d14acf16845f587..9fc4c2226b0371ab628e22a56e3a947810e86dbb 100644 (file)
@@ -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);