diff mbox series

[v2,1/3] cxl: Add check for NULL ptr after calling find_cxl_root()

Message ID 170439742132.3519628.18244037289884549403.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
In cxl_port_perf_data_calculate, the function fails to check for NULL ptr
after calling find_cxl_root(). Add check to avoid NULL ptr dereferencing.

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 |    3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/drivers/cxl/core/cdat.c b/drivers/cxl/core/cdat.c
index cd84d87f597a..3dce4a201ddd 100644
--- a/drivers/cxl/core/cdat.c
+++ b/drivers/cxl/core/cdat.c
@@ -176,6 +176,9 @@  static int cxl_port_perf_data_calculate(struct cxl_port *port,
 	}
 
 	root_port = find_cxl_root(port);
+	if (!root_port)
+		return -ENODEV;
+
 	cxl_root = to_cxl_root(root_port);
 	if (!cxl_root->ops || !cxl_root->ops->qos_class)
 		return -EOPNOTSUPP;