mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] cxl/hdm: Fix potential infinite loop in __cxl_dpa_reserve()
@ 2026-01-12 12:05 Li Ming
  2026-01-12 15:35 ` Dave Jiang
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Li Ming @ 2026-01-12 12:05 UTC (permalink / raw)
  To: dave, jonathan.cameron, dave.jiang, alison.schofield,
	vishal.l.verma, ira.weiny, dan.j.williams
  Cc: linux-cxl, linux-kernel, 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_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@zohomail.com>
---
 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;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] cxl/hdm: Fix potential infinite loop in __cxl_dpa_reserve()
  2026-01-12 12:05 [PATCH 1/1] cxl/hdm: Fix potential infinite loop in __cxl_dpa_reserve() Li Ming
@ 2026-01-12 15:35 ` Dave Jiang
  2026-01-12 15:55 ` Ira Weiny
  2026-01-12 16:03 ` Dave Jiang
  2 siblings, 0 replies; 5+ messages in thread
From: Dave Jiang @ 2026-01-12 15:35 UTC (permalink / raw)
  To: Li Ming, dave, jonathan.cameron, alison.schofield,
	vishal.l.verma, ira.weiny, dan.j.williams
  Cc: linux-cxl, linux-kernel



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@zohomail.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> ---
>  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;


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] cxl/hdm: Fix potential infinite loop in __cxl_dpa_reserve()
  2026-01-12 12:05 [PATCH 1/1] cxl/hdm: Fix potential infinite loop in __cxl_dpa_reserve() Li Ming
  2026-01-12 15:35 ` Dave Jiang
@ 2026-01-12 15:55 ` Ira Weiny
  2026-01-12 16:03 ` Dave Jiang
  2 siblings, 0 replies; 5+ messages in thread
From: Ira Weiny @ 2026-01-12 15:55 UTC (permalink / raw)
  To: Li Ming, dave, jonathan.cameron, dave.jiang, alison.schofield,
	vishal.l.verma, ira.weiny, dan.j.williams
  Cc: linux-cxl, linux-kernel, Li Ming

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")

Technically the bug was introduced in:

Fixes: 991d98f17d31 ("cxl: Make cxl_dpa_alloc() DPA partition number agnostic")

With that,
Reviewed-by: Ira Weiny <ira.weiny@intel.com>

[snip]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] cxl/hdm: Fix potential infinite loop in __cxl_dpa_reserve()
  2026-01-12 12:05 [PATCH 1/1] cxl/hdm: Fix potential infinite loop in __cxl_dpa_reserve() Li Ming
  2026-01-12 15:35 ` Dave Jiang
  2026-01-12 15:55 ` Ira Weiny
@ 2026-01-12 16:03 ` Dave Jiang
  2026-01-12 18:02   ` [PATCH] " Markus Elfring
  2 siblings, 1 reply; 5+ messages in thread
From: Dave Jiang @ 2026-01-12 16:03 UTC (permalink / raw)
  To: Li Ming, dave, jonathan.cameron, alison.schofield,
	vishal.l.verma, ira.weiny, dan.j.williams
  Cc: linux-cxl, linux-kernel



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@zohomail.com>

Applied to cxl/fixes with Fixes tag fixed
d4026a44626490dc4eca4dd2c4d0816338fa179b

> ---
>  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;


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cxl/hdm: Fix potential infinite loop in __cxl_dpa_reserve()
  2026-01-12 16:03 ` Dave Jiang
@ 2026-01-12 18:02   ` Markus Elfring
  0 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2026-01-12 18:02 UTC (permalink / raw)
  To: Dave Jiang, Li Ming, linux-cxl, Alison Schofield, Dan Williams,
	Davidlohr Bueso, Ira Weiny, Jonathan Cameron, Vishal Verma
  Cc: LKML

> > 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
…

How do you think about to avoid typos in such a change description?


> Applied to cxl/fixes with Fixes tag fixed
> d4026a44626490dc4eca4dd2c4d0816338fa179b

Is this adjustment still improvable?

Regards,
Markus

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-01-12 18:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-12 12:05 [PATCH 1/1] cxl/hdm: Fix potential infinite loop in __cxl_dpa_reserve() Li Ming
2026-01-12 15:35 ` Dave Jiang
2026-01-12 15:55 ` Ira Weiny
2026-01-12 16:03 ` Dave Jiang
2026-01-12 18:02   ` [PATCH] " Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®