cxl/region: Cleanup target list on attach error
authorDan Williams <dan.j.williams@intel.com>
Fri, 10 Feb 2023 09:06:09 +0000 (01:06 -0800)
committerDan Williams <dan.j.williams@intel.com>
Sat, 11 Feb 2023 01:32:21 +0000 (17:32 -0800)
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
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/167601996980.1924368.390423634911157277.stgit@dwillia2-xfh.jf.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/core/region.c

index 040bbd39c81d1f9ede803d601c4a984a89be536f..ae7d3adcd41a3459013258bd4424b97fca448ef1 100644 (file)
@@ -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))