Skip to content

Commit 2816e24

Browse files
jic23djbw
authored andcommitted
cxl/region: Fix null pointer dereference due to pass through decoder commit
Not all decoders have a commit callback. The CXL specification allows a host bridge with a single root port to have no explicit HDM decoders. Currently the region driver assumes there are none. As such the CXL core creates a special pass through decoder instance without a commit callback. Prior to this patch, the ->commit() callback was called unconditionally. Thus a configuration with 1 Host Bridge, 1 Root Port, 1 switch with multiple downstream ports below which there are multiple CXL type 3 devices results in a situation where committing the region causes a null pointer dereference. Reported-by: Bobo WL <[email protected]> Fixes: 176baef ("cxl/hdm: Commit decoder state to hardware") Signed-off-by: Jonathan Cameron <[email protected]> Reviewed-by: Vishal Verma <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent cf00b33 commit 2816e24

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/cxl/core/region.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ static int cxl_region_decode_commit(struct cxl_region *cxlr)
174174
iter = to_cxl_port(iter->dev.parent)) {
175175
cxl_rr = cxl_rr_load(iter, cxlr);
176176
cxld = cxl_rr->decoder;
177-
rc = cxld->commit(cxld);
177+
if (cxld->commit)
178+
rc = cxld->commit(cxld);
178179
if (rc)
179180
break;
180181
}

0 commit comments

Comments
 (0)