Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cxl/acpi: Fail decoder add if CXIMS for HBIG is missing

The BIOS provided CXIMS (CXL XOR Interleave Math Structure) is required
for calculating a targets position in an interleave list during region
creation. The CXL driver expects to discover a CXIMS that matches the
HBIG (Host Bridge Interleave Granularity) and stores the xormaps found
in that CXIMS for retrieval during region creation.

If there is no CXIMS for an HBIG, no maps are stored. That leads to a
NULL pointer dereference at xormap retrieval during region creation.

Add a check during ACPI probe for the case of no matching CXIMS. Emit
an error message and fail to add the decoder.

Fixes: f9db85bfec0d ("cxl/acpi: Support CXL XOR Interleave Math (CXIMS)")
Suggested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20221205002951.1788783-1-alison.schofield@intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

authored by

Alison Schofield and committed by
Dan Williams
14628aec cb4cdf74

+5
+5
drivers/cxl/acpi.c
··· 282 282 cxl_parse_cxims, &cxims_ctx); 283 283 if (rc < 0) 284 284 goto err_xormap; 285 + if (!cxlrd->platform_data) { 286 + dev_err(dev, "No CXIMS for HBIG %u\n", ig); 287 + rc = -EINVAL; 288 + goto err_xormap; 289 + } 285 290 } 286 291 } 287 292 rc = cxl_decoder_add(cxld, target_map);