This is a note to let you know that I've just added the patch titled cxl/region: Fix cxl_region leak, cleanup targets at region delete to the 6.0-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-fix-cxl_region-leak-cleanup-targets-at-region-delete.patch and it can be found in the queue-6.0 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 0d9e734018d70cecf79e2e4c6082167160a0f13f Mon Sep 17 00:00:00 2001 From: Dan Williams <dan.j.williams@xxxxxxxxx> Date: Thu, 3 Nov 2022 17:30:30 -0700 Subject: cxl/region: Fix cxl_region leak, cleanup targets at region delete From: Dan Williams <dan.j.williams@xxxxxxxxx> commit 0d9e734018d70cecf79e2e4c6082167160a0f13f upstream. When a region is deleted any targets that have been previously assigned to that region hold references to it. Trigger those references to drop by detaching all targets at unregister_region() time. Otherwise that region object will leak as userspace has lost the ability to detach targets once region sysfs is torn down. Cc: <stable@xxxxxxxxxxxxxxx> Fixes: b9686e8c8e39 ("cxl/region: Enable the assignment of endpoint decoders to regions") Reviewed-by: Dave Jiang <dave.jiang@xxxxxxxxx> Reviewed-by: Vishal Verma <vishal.l.verma@xxxxxxxxx> Link: https://lore.kernel.org/r/166752183055.947915.17681995648556534844.stgit@xxxxxxxxxxxxxxxxxxxxxxxxx Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/cxl/core/region.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -1556,8 +1556,19 @@ static struct cxl_region *to_cxl_region( static void unregister_region(void *dev) { struct cxl_region *cxlr = to_cxl_region(dev); + struct cxl_region_params *p = &cxlr->params; + int i; device_del(dev); + + /* + * Now that region sysfs is shutdown, the parameter block is now + * read-only, so no need to hold the region rwsem to access the + * region parameters. + */ + for (i = 0; i < p->interleave_ways; i++) + detach_target(cxlr, i); + cxl_region_iomem_release(cxlr); put_device(dev); } Patches currently in stable-queue which might be from dan.j.williams@xxxxxxxxx are queue-6.0/cxl-region-fix-distance-calculation-with-passthrough-ports.patch queue-6.0/acpi-numa-add-cxl-cfmws-nodes-to-the-possible-nodes-set.patch queue-6.0/cxl-region-fix-decoder-allocation-crash.patch queue-6.0/cxl-pmem-fix-cxl_pmem_region-and-cxl_memdev-leak.patch queue-6.0/cxl-region-fix-region-hpa-ordering-validation.patch queue-6.0/cxl-region-fix-cxl_region-leak-cleanup-targets-at-region-delete.patch