aboutsummaryrefslogtreecommitdiff
path: root/drivers/cxl
diff options
context:
space:
mode:
authorDan Williams2022-02-10 17:04:42 -0800
committerDan Williams2022-02-17 16:50:30 -0800
commit41ae9105f5e23e98a1734be2eeddddf488e42c2e (patch)
tree9e6eab847326214ba6b7f4ea5829a8eef85b63df /drivers/cxl
parente6e17cc6ed751072513fe16cb595ac09f6821a43 (diff)
cxl/port: Fix endpoint refcount leak
An endpoint can be unregistered via two paths. Either its parent port is unregistered, or the memdev that registered the endpoint is removed. The memdev remove path is responsible for synchronizing against the parent ->remove() event and if the memdev remove path wins, manually trigger unregister_port() via devm_release_action(). Until that race is resolved the memdev remove path holds a reference on the endpoint. If the parent port for the endpoint can not be found that is an indication that the endpoint has already been registered. Be sure to drop the reference in all exit paths from delete_endpoint(). Fixes: 8dd2bc0f8e02 ("cxl/mem: Add the cxl_mem driver") Link: https://lore.kernel.org/r/164454148209.3429624.12905500880311609053.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/cxl')
-rw-r--r--drivers/cxl/core/port.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index d29eb2abdbc2..0fc1441be014 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -850,7 +850,7 @@ static void delete_endpoint(void *data)
parent_port = cxl_mem_find_port(cxlmd);
if (!parent_port)
- return;
+ goto out;
parent = &parent_port->dev;
cxl_device_lock(parent);
@@ -860,6 +860,7 @@ static void delete_endpoint(void *data)
}
cxl_device_unlock(parent);
put_device(parent);
+out:
put_device(&endpoint->dev);
}