]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cxl/core: Check existence of cxl_memdev_state in poison test
authorAlison Schofield <alison.schofield@intel.com>
Tue, 31 Mar 2026 00:50:45 +0000 (17:50 -0700)
committerDave Jiang <dave.jiang@intel.com>
Tue, 31 Mar 2026 22:18:06 +0000 (15:18 -0700)
Before now, all CXL memdevs were assumed to have a mailbox-backed
cxl_memdev_state, so poison command checks could safely dereference
the @mds.

With the introduction of Type 2 devices, a memdev may not implement
a mailbox interface, and so there is no associated cxl_memdev_state.
Guard against this case by returning false when @mds is absent.

Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Alejandro Lucero <alucerop@amd.com>
Link: https://patch.msgid.link/20260331005047.2813980-1-alison.schofield@intel.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
drivers/cxl/core/memdev.c

index 273c22118d3d8bd5cece2ce5416a6319447ab6c7..591425866045bcebd0391aa87a02b047caf87381 100644 (file)
@@ -204,6 +204,9 @@ bool cxl_memdev_has_poison_cmd(struct cxl_memdev *cxlmd,
 {
        struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds);
 
+       if (!mds)
+               return 0;
+
        return test_bit(cmd, mds->poison.enabled_cmds);
 }