Skip to content

Commit 41ae910

Browse files
committed
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: 8dd2bc0 ("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>
1 parent e6e17cc commit 41ae910

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/cxl/core/port.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ static void delete_endpoint(void *data)
850850

851851
parent_port = cxl_mem_find_port(cxlmd);
852852
if (!parent_port)
853-
return;
853+
goto out;
854854
parent = &parent_port->dev;
855855

856856
cxl_device_lock(parent);
@@ -860,6 +860,7 @@ static void delete_endpoint(void *data)
860860
}
861861
cxl_device_unlock(parent);
862862
put_device(parent);
863+
out:
863864
put_device(&endpoint->dev);
864865
}
865866

0 commit comments

Comments
 (0)