This is a note to let you know that I've just added the patch titled cxl/region: Cleanup target list on attach error to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: cxl-region-cleanup-target-list-on-attach-error.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 65f8fb7bee685e8ad3b815764a0f4d21afe736ff Author: Dan Williams <dan.j.williams@xxxxxxxxx> Date: Fri Feb 10 01:06:09 2023 -0800 cxl/region: Cleanup target list on attach error [ Upstream commit 86987c766276acf1289700cd38bd6d5b5a167fea ] 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@xxxxxxxxxx> Link: http://lore.kernel.org/r/20230208123031.00006990@xxxxxxxxxx Reviewed-by: Ira Weiny <ira.weiny@xxxxxxxxx> Reviewed-by: Vishal Verma <vishal.l.verma@xxxxxxxxx> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> Link: https://lore.kernel.org/r/167601996980.1924368.390423634911157277.stgit@xxxxxxxxxxxxxxxxxxxxxxxxx Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx> Stable-dep-of: 0718588c7aaa ("cxl/region: Do not try to cleanup after cxl_region_setup_targets() fails") Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 99b0501066e57..bd1c511bba987 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1317,6 +1317,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))