cxl/hdm: Fix potential infinite loop in __cxl_dpa_reserve()
Li Ming
reviewerPATCH 1/1 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.
--- drivers/cxl/core/hdm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/core/hdm.c +1 -1
@@ -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 ;
Signature · 1 line
2.34.1
Quoted 8 lines · Li Ming
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_paritionsis 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 <[email protected]>
Quoted 17 lines
--- drivers/cxl/core/hdm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cxl/core/hdm.c +1
-1@@ -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 ;
Quoted 7 lines · Li Ming
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_paritionsis 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")
Technically the bug was introduced in:
With that,
[snip]
Quoted 8 lines · Li Ming
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_paritionsis 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 <[email protected]>
Applied to cxl/fixes with Fixes tag fixedd4026a44626490dc4eca4dd2c4d0816338fa179b
Quoted 17 lines
--- drivers/cxl/core/hdm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/cxl/core/hdm.c +1
-1@@ -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 ;
Quoted 3 lines
Quoted 3 lines
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_paritionsis used to represent how many partitions information
…
How do you think about to avoid typos in such a change description?
Quoted 2 lines
Applied to cxl/fixes with Fixes tag fixed
d4026a44626490dc4eca4dd2c4d0816338fa179b
Is this adjustment still improvable?
Regards,
Markus