Re: [PATCH] cxl/core: Check existence of cxl_memdev_state in poison test

Dave Jiang
2026-04-01T17:19:52Z

On 3/30/26 5:50 PM, Alison Schofield wrote:
> 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>

Applied to cxl/next
261a02b93d9b

> ---
> drivers/cxl/core/memdev.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
> index 273c22118d3d..591425866045 100644
> --- a/drivers/cxl/core/memdev.c
> +++ b/drivers/cxl/core/memdev.c
> @@ -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);
> }
>