linux-cxl.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cxl/port: Fix endpoint refcount leak
@ 2022-02-11  1:04 Dan Williams
  0 siblings, 0 replies; only message in thread
From: Dan Williams @ 2022-02-11  1:04 UTC (permalink / raw)
  To: linux-cxl; +Cc: ben.widawsky

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")
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/cxl/core/port.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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);
 }
 


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-02-11  1:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-11  1:04 [PATCH] cxl/port: Fix endpoint refcount leak Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).