Message ID | 20250319134339.3114817-1-ioana.ciornei@nxp.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Bjorn Helgaas |
Headers | show |
Series | PCI: dwc: don't assume the ops field in dw_pcie always exists | expand |
On Wed, Mar 19, 2025 at 03:43:39PM +0200, Ioana Ciornei wrote: > 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> > --- Reviewed-by: Frank Li <Frank.Li@nxp.com> Bjorn: you may squah to previous's commit. Frank > 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, ®_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 >
On Wed, Mar 19, 2025 at 03:43:39PM +0200, Ioana Ciornei wrote: > 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> Thank you very much! Squashed into the "PCI: dwc: Add dw_pcie_parent_bus_offset() checking and debug" commit so there will be no bisection hole for this. > --- > 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, ®_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 >
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, ®_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) {
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(-)