Skip to content

Commit 09ceba3

Browse files
MingLi-4davejiang
authored andcommitted
cxl/pci: Check dport->regs.rcd_pcie_cap availability before accessing
RCD Upstream Port's PCI Express Capability is a component registers block stored in RCD Upstream Port RCRB. CXL PCI driver helps to map it during the RCD probing, but mapping failure is allowed for component registers blocks in CXL PCI driver. dport->regs.rcd_pcie_cap is used to store the virtual address of the RCD Upstream Port's PCI Express Capability, add a dport->regs.rcd_pcie_cap checking in rcd_pcie_cap_emit() just in case user accesses a invalid address via RCD sysfs. Fixes: c5eaec7 ("cxl/pci: Add sysfs attribute for CXL 1.1 device link status") Signed-off-by: Li Ming <[email protected]> Reviewed-by: Alison Schofield <[email protected]> Reviewed-by: Dan Williams <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Dave Jiang <[email protected]>
1 parent da4d8c8 commit 09ceba3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/cxl/pci.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,9 @@ static ssize_t rcd_pcie_cap_emit(struct device *dev, u16 offset, char *buf, size
836836
if (!root_dev)
837837
return -ENXIO;
838838

839+
if (!dport->regs.rcd_pcie_cap)
840+
return -ENXIO;
841+
839842
guard(device)(root_dev);
840843
if (!root_dev->driver)
841844
return -ENXIO;

0 commit comments

Comments
 (0)