]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cxl/acpi: Restore HBIW check before dereferencing platform_data
authorAlison Schofield <alison.schofield@intel.com>
Fri, 9 Jan 2026 19:49:44 +0000 (11:49 -0800)
committerDave Jiang <dave.jiang@intel.com>
Sat, 10 Jan 2026 00:12:03 +0000 (17:12 -0700)
Commit 4fe516d2ad1a ("cxl/acpi: Make the XOR calculations available
for testing") split xormap handling code to create a reusable helper
function but inadvertently dropped the check of HBIW values before
dereferencing cxlrd->platform_data. When HBIW is 1 or 3, no xormaps
are needed and platform_data may be NULL, leading to a potential NULL
pointer dereference.

Affects platform configs using XOR Arithmetic with HBIWs of 1 or 3,
when performing DPA->HPA address translation for CXL events. Those
events would be any of poison ops, general media, or dram.

Restore the early return check for HBIW values of 1 and 3 before
dereferencing platform_data.

Fixes: 4fe516d2ad1a ("cxl/acpi: Make the XOR calculations available for testing")
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://patch.msgid.link/20260109194946.431083-1-alison.schofield@intel.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
drivers/cxl/acpi.c

index 77ac940e30138c0a4c7b8869b96b9bbc2b5124da..49bba2b9a3c45dbe6bb9c7056bb2ed9c4ad56498 100644 (file)
@@ -75,9 +75,16 @@ EXPORT_SYMBOL_FOR_MODULES(cxl_do_xormap_calc, "cxl_translate");
 
 static u64 cxl_apply_xor_maps(struct cxl_root_decoder *cxlrd, u64 addr)
 {
-       struct cxl_cxims_data *cximsd = cxlrd->platform_data;
+       int hbiw = cxlrd->cxlsd.nr_targets;
+       struct cxl_cxims_data *cximsd;
+
+       /* No xormaps for host bridge interleave ways of 1 or 3 */
+       if (hbiw == 1 || hbiw == 3)
+               return addr;
+
+       cximsd = cxlrd->platform_data;
 
-       return cxl_do_xormap_calc(cximsd, addr, cxlrd->cxlsd.nr_targets);
+       return cxl_do_xormap_calc(cximsd, addr, hbiw);
 }
 
 struct cxl_cxims_context {