[PATCH] cxl/ras: Fix match_memdev_by_parent() pointer type mismatch

From: Terry Bowman

Date: Mon Jun 08 2026 - 18:43:58 EST


bus_find_device() passes its data argument directly to the match
function as a const void *. match_memdev_by_parent() compares
dev->parent against this pointer:

dev->parent == uport

cxlmd->dev.parent is set in cxl_memdev_alloc() as:

dev->parent = cxlds->dev; /* cxlds->dev == &pdev->dev */

So cxlmd->dev.parent holds a struct device * pointing to &pdev->dev.
However, bus_find_device() is called with pdev (struct pci_dev *)
rather than &pdev->dev (struct device *). Since struct pci_dev does
not begin with struct device, the two pointer values differ, causing
the comparison to always evaluate false.

As a result, cxl_cper_handle_prot_err() silently drops every CPER
error report for CXL endpoint devices -- bus_find_device() always
returns NULL and the function returns early without emitting any
kernel trace event.

Fix by passing &pdev->dev instead of pdev.

Fixes: 3c70ec71abda ("cxl/ras: Fix CPER handler device confusion")
Reported-by: Sashiko <sashiko@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Terry Bowman <terry.bowman@xxxxxxx>
---
drivers/cxl/core/ras.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/cxl/core/ras.c b/drivers/cxl/core/ras.c
index 006c6ffc2f56..7ec2dab152a7 100644
--- a/drivers/cxl/core/ras.c
+++ b/drivers/cxl/core/ras.c
@@ -94,8 +94,7 @@ void cxl_cper_handle_prot_err(struct cxl_cper_prot_err_work_data *data)
if (!pdev->dev.driver)
return;

- struct device *mem_dev __free(put_device) = bus_find_device(
- &cxl_bus_type, NULL, pdev, match_memdev_by_parent);
+ struct device *mem_dev __free(put_device) = bus_find_device(&cxl_bus_type, NULL, &pdev->dev, match_memdev_by_parent);
if (!mem_dev)
return;

--
2.34.1