Re: [PATCH 1/1] cxl/hdm: Fix potential infinite loop in __cxl_dpa_reserve()
From: Dave Jiang
Date: Mon Jan 12 2026 - 10:35:39 EST
On 1/12/26 5:05 AM, Li Ming wrote:
> In __cxl_dpa_reserve(), it will check if the new resource range is
> included in one of paritions of the cxl memory device.
> cxlds->nr_paritions is used to represent how many partitions information
> the cxl memory device has. In the loop, if driver cannot find a
> partition including the new resource range, it will be an infinite loop.
>
> Fixes: be5cbd084027 ("cxl: Kill enum cxl_decoder_mode")
> Signed-off-by: Li Ming <ming.li@xxxxxxxxxxxx>
Reviewed-by: Dave Jiang <dave.jiang@xxxxxxxxx>
> ---
> drivers/cxl/core/hdm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
> index 1c5d2022c87a..a470099a69f1 100644
> --- a/drivers/cxl/core/hdm.c
> +++ b/drivers/cxl/core/hdm.c
> @@ -403,7 +403,7 @@ static int __cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled,
> * is not set.
> */
> if (cxled->part < 0)
> - for (int i = 0; cxlds->nr_partitions; i++)
> + for (int i = 0; i < cxlds->nr_partitions; i++)
> if (resource_contains(&cxlds->part[i].res, res)) {
> cxled->part = i;
> break;