Skip to content
/ linux Public

Commit 0f514a9

Browse files
Sergey ShtylyovSasha Levin
authored andcommitted
PCI: Check parent for NULL in of_pci_bus_release_domain_nr()
[ Upstream commit f724590 ] 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: c14f7cc ("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 Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f4a681c commit 0f514a9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/pci/pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6886,7 +6886,7 @@ static void of_pci_bus_release_domain_nr(struct device *parent, int domain_nr)
68866886
return;
68876887

68886888
/* Release domain from IDA where it was allocated. */
6889-
if (of_get_pci_domain_nr(parent->of_node) == domain_nr)
6889+
if (parent && of_get_pci_domain_nr(parent->of_node) == domain_nr)
68906890
ida_free(&pci_domain_nr_static_ida, domain_nr);
68916891
else
68926892
ida_free(&pci_domain_nr_dynamic_ida, domain_nr);

0 commit comments

Comments
 (0)