Skip to content

Commit 0d9e734

Browse files
committed
cxl/region: Fix cxl_region leak, cleanup targets at region delete
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@vger.kernel.org> Fixes: b9686e8 ("cxl/region: Enable the assignment of endpoint decoders to regions") Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Vishal Verma <vishal.l.verma@intel.com> Link: https://lore.kernel.org/r/166752183055.947915.17681995648556534844.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent a90accb commit 0d9e734

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/cxl/core/region.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,8 +1557,19 @@ static struct cxl_region *to_cxl_region(struct device *dev)
15571557
static void unregister_region(void *dev)
15581558
{
15591559
struct cxl_region *cxlr = to_cxl_region(dev);
1560+
struct cxl_region_params *p = &cxlr->params;
1561+
int i;
15601562

15611563
device_del(dev);
1564+
1565+
/*
1566+
* Now that region sysfs is shutdown, the parameter block is now
1567+
* read-only, so no need to hold the region rwsem to access the
1568+
* region parameters.
1569+
*/
1570+
for (i = 0; i < p->interleave_ways; i++)
1571+
detach_target(cxlr, i);
1572+
15621573
cxl_region_iomem_release(cxlr);
15631574
put_device(dev);
15641575
}

0 commit comments

Comments
 (0)