Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cxl/hdm: Fix potential infinite loop in __cxl_dpa_reserve()

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.

[ dj: Removed incorrect fixes tag ]

Fixes: 991d98f17d31 ("cxl: Make cxl_dpa_alloc() DPA partition number agnostic")
Signed-off-by: Li Ming <ming.li@zohomail.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://patch.msgid.link/20260112120526.530232-1-ming.li@zohomail.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>

authored by

Li Ming and committed by
Dave Jiang
d4026a44 49d10634

+1 -1
+1 -1
drivers/cxl/core/hdm.c
··· 403 403 * is not set. 404 404 */ 405 405 if (cxled->part < 0) 406 - for (int i = 0; cxlds->nr_partitions; i++) 406 + for (int i = 0; i < cxlds->nr_partitions; i++) 407 407 if (resource_contains(&cxlds->part[i].res, res)) { 408 408 cxled->part = i; 409 409 break;