diff mbox series

[v2,08/20] cxl/region: Cleanup target list on attach error

Message ID 167601996980.1924368.390423634911157277.stgit@dwillia2-xfh.jf.intel.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series CXL RAM and the 'Soft Reserved' => 'System RAM' default | expand

Commit Message

Dan Williams Feb. 10, 2023, 9:06 a.m. UTC
Jonathan noticed that the target list setup is not unwound completely
upon error. Undo all the setup in the 'err_decrement:' exit path.

Fixes: 27b3f8d13830 ("cxl/region: Program target lists")
Reported-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Link: http://lore.kernel.org/r/20230208123031.00006990@Huawei.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/cxl/core/region.c |    2 ++
 1 file changed, 2 insertions(+)

Comments

Jonathan Cameron Feb. 10, 2023, 5:31 p.m. UTC | #1
On Fri, 10 Feb 2023 01:06:09 -0800
Dan Williams <dan.j.williams@intel.com> wrote:

> Jonathan noticed that the target list setup is not unwound completely
> upon error. Undo all the setup in the 'err_decrement:' exit path.
> 
> Fixes: 27b3f8d13830 ("cxl/region: Program target lists")
> Reported-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
> Link: http://lore.kernel.org/r/20230208123031.00006990@Huawei.com
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/cxl/core/region.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 040bbd39c81d..ae7d3adcd41a 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -1347,6 +1347,8 @@ static int cxl_region_attach(struct cxl_region *cxlr,
>  
>  err_decrement:
>  	p->nr_targets--;
> +	cxled->pos = -1;
> +	p->targets[pos] = NULL;
>  err:
>  	for (iter = ep_port; !is_cxl_root(iter);
>  	     iter = to_cxl_port(iter->dev.parent))
> 
>
Verma, Vishal L Feb. 10, 2023, 11:17 p.m. UTC | #2
On Fri, 2023-02-10 at 01:06 -0800, Dan Williams wrote:
> Jonathan noticed that the target list setup is not unwound completely
> upon error. Undo all the setup in the 'err_decrement:' exit path.
> 
> Fixes: 27b3f8d13830 ("cxl/region: Program target lists")
> Reported-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
> Link: http://lore.kernel.org/r/20230208123031.00006990@Huawei.com
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  drivers/cxl/core/region.c |    2 ++
>  1 file changed, 2 insertions(+)

Looks good,

Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>

> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 040bbd39c81d..ae7d3adcd41a 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -1347,6 +1347,8 @@ static int cxl_region_attach(struct cxl_region *cxlr,
>  
>  err_decrement:
>         p->nr_targets--;
> +       cxled->pos = -1;
> +       p->targets[pos] = NULL;
>  err:
>         for (iter = ep_port; !is_cxl_root(iter);
>              iter = to_cxl_port(iter->dev.parent))
>
Ira Weiny Feb. 10, 2023, 11:46 p.m. UTC | #3
Dan Williams wrote:
> Jonathan noticed that the target list setup is not unwound completely
> upon error. Undo all the setup in the 'err_decrement:' exit path.
> 
> Fixes: 27b3f8d13830 ("cxl/region: Program target lists")
> Reported-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>

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

> Link: http://lore.kernel.org/r/20230208123031.00006990@Huawei.com
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  drivers/cxl/core/region.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 040bbd39c81d..ae7d3adcd41a 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -1347,6 +1347,8 @@ static int cxl_region_attach(struct cxl_region *cxlr,
>  
>  err_decrement:
>  	p->nr_targets--;
> +	cxled->pos = -1;
> +	p->targets[pos] = NULL;
>  err:
>  	for (iter = ep_port; !is_cxl_root(iter);
>  	     iter = to_cxl_port(iter->dev.parent))
> 
>
diff mbox series

Patch

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 040bbd39c81d..ae7d3adcd41a 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -1347,6 +1347,8 @@  static int cxl_region_attach(struct cxl_region *cxlr,
 
 err_decrement:
 	p->nr_targets--;
+	cxled->pos = -1;
+	p->targets[pos] = NULL;
 err:
 	for (iter = ep_port; !is_cxl_root(iter);
 	     iter = to_cxl_port(iter->dev.parent))