linux/drivers/pci/endpoint
Manivannan Sadhasivam 0cca961a02
PCI: Pass domain number to pci_bus_release_domain_nr() explicitly
The pci_bus_release_domain_nr() API is supposed to free the domain
number allocated by pci_bus_find_domain_nr(). Most of the callers of
pci_bus_find_domain_nr(), store the domain number in pci_bus::domain_nr.

As such, the pci_bus_release_domain_nr() implicitly frees the domain
number by dereferencing 'struct pci_bus'. However, one of the callers
of this API, the PCI endpoint subsystem, doesn't have 'struct pci_bus',
so it only passes NULL. Due to this, the API will end up dereferencing
the NULL pointer.

To fix this issue, pass the domain number to this API explicitly. Since
'struct pci_bus' is not used for anything else other than extracting the
domain number, it makes sense to pass the domain number directly.

Fixes: 0328947c50 ("PCI: endpoint: Assign PCI domain number for endpoint controllers")
Closes: https://lore.kernel.org/linux-pci/c0c40ddb-bf64-4b22-9dd1-8dbb18aa2813@stanley.mountain
Link: https://lore.kernel.org/linux-pci/20240912053025.25314-1-manivannan.sadhasivam@linaro.org
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
[kwilczynski: commit log]
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
2024-09-13 22:12:29 +00:00
..
functions Merge branch 'pci/controller/qcom' 2024-07-19 10:10:31 -05:00
Kconfig PCI: consolidate PCI config entry in drivers/pci 2018-11-23 11:45:34 +09:00
Makefile PCI: Add SPDX GPL-2.0 when no license was specified 2018-01-26 11:45:16 -06:00
pci-ep-cfs.c PCI: endpoint: Remove unused field in struct pci_epf_group 2024-05-28 11:13:48 -05:00
pci-epc-core.c PCI: Pass domain number to pci_bus_release_domain_nr() explicitly 2024-09-13 22:12:29 +00:00
pci-epc-mem.c PCI: endpoint: Add kernel-doc for pci_epc_mem_init() API 2023-08-26 16:54:46 +00:00
pci-epf-core.c driver core: have match() callback in struct bus_type take a const * 2024-07-03 15:16:54 +02:00