diff mbox series

[v2,2/3] cxl: Add missing device dereference after find_cxl_root()

Message ID 170439742837.3519628.14026339143178956408.stgit@djiang5-mobl3
State Superseded
Headers show
Series [v2,1/3] cxl: Add check for NULL ptr after calling find_cxl_root() | expand

Commit Message

Dave Jiang Jan. 4, 2024, 7:43 p.m. UTC
find_cxl_root() takes a reference on the 'struct device' before returning.
A put_device() is needed when once the root port is no longer needed.
cxl_port_perf_data_calculate() fails to dereference device. Add a __free()
call to make sure the device reference is decremented when done.

Fixes: 7a4f148dd8d5 ("cxl: Compute the entire CXL path latency and bandwidth data")
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 drivers/cxl/core/cdat.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/cxl/core/cdat.c b/drivers/cxl/core/cdat.c
index 3dce4a201ddd..701ed53ce337 100644
--- a/drivers/cxl/core/cdat.c
+++ b/drivers/cxl/core/cdat.c
@@ -162,7 +162,7 @@  static int cxl_port_perf_data_calculate(struct cxl_port *port,
 					struct xarray *dsmas_xa)
 {
 	struct access_coordinate c;
-	struct cxl_port *root_port;
+	struct cxl_port *root_port __free(put_device) = NULL;
 	struct cxl_root *cxl_root;
 	struct dsmas_entry *dent;
 	int valid_entries = 0;