Re: [PATCH 1/1] cxl/pmem: debug invalid serial number data
From: Fan Ni
Date: Thu Feb 13 2025 - 13:22:44 EST
On Thu, Feb 13, 2025 at 02:40:08PM +0800, Yuquan Wang wrote:
> In a nvdimm interleave-set each device with an invalid or zero
> serial number may cause pmem region initialization to fail, but in
> cxl case such device could still set cookies of nd_interleave_set
> and create a nvdimm pmem region.
>
> This adds the validation of serial number in cxl pmem region creation.
> The event of no serial number would cause to fail to set the cookie
> and pmem region.
>
> Signed-off-by: Yuquan Wang <wangyuquan1236@xxxxxxxxxxxxxx>
> ---
> drivers/cxl/pmem.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/cxl/pmem.c b/drivers/cxl/pmem.c
> index f9c95996e937..89f4eac49313 100644
> --- a/drivers/cxl/pmem.c
> +++ b/drivers/cxl/pmem.c
> @@ -384,6 +384,13 @@ static int cxl_pmem_region_probe(struct device *dev)
> };
> info[i].offset = m->start;
> info[i].serial = cxlds->serial;
> +
> + if (info[i].serial == 0) {
> + dev_dbg(dev, "%s: invalid serial number\n",
Should we use dev_err() instead?
Fan
> + dev_name(&cxlmd->dev));
> + rc = -ENXIO;
> + goto out_nvd;
> + }
> }
> ndr_desc.num_mappings = cxlr_pmem->nr_mappings;
> ndr_desc.mapping = mappings;
> --
> 2.34.1
>