Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI: dwc: don't assume the ops field in dw_pcie always exists
@ 2025-03-19 13:43 Ioana Ciornei
  2025-03-19 14:06 ` Frank Li
  2025-03-19 17:18 ` Bjorn Helgaas
  0 siblings, 2 replies; 3+ messages in thread
From: Ioana Ciornei @ 2025-03-19 13:43 UTC (permalink / raw)
  To: Bjorn Helgaas, Frank Li
  Cc: Jingoo Han, Manivannan Sadhasivam, Lorenzo Pieralisi, kw,
	Rob Herring, linux-pci, linux-kernel

The blamed commit assumes that the ops field from dw_pcie is always
populated. This is not the case for the layerscape-pcie driver which
does not provide a dw_pcie_ops structure. The newly added
dw_pcie_parent_bus_offset() function tries to dereference pci->ops
which, in this case, is NULL.

Fix this by first checking if pci->ops is valid before dereferencing it.

Fixes: ed6509230934 ("PCI: dwc: Add dw_pcie_parent_bus_offset() checking and debug")
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/pci/controller/dwc/pcie-designware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index e68e2aac210f..b5fd44c0d6ad 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -1170,7 +1170,7 @@ resource_size_t dw_pcie_parent_bus_offset(struct dw_pcie *pci,
 
 	of_property_read_reg(np, index, &reg_addr, NULL);
 
-	fixup = pci->ops->cpu_addr_fixup;
+	fixup = pci->ops ? pci->ops->cpu_addr_fixup : 0;
 	if (fixup) {
 		fixup_addr = fixup(pci, cpu_phy_addr);
 		if (reg_addr == fixup_addr) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-19 17:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-19 13:43 [PATCH] PCI: dwc: don't assume the ops field in dw_pcie always exists Ioana Ciornei
2025-03-19 14:06 ` Frank Li
2025-03-19 17:18 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox