diff mbox series

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

Message ID 170440924347.3570725.6271367271629367301.stgit@djiang5-mobl3
State New, archived
Headers show
Series [v3,1/4] cxl: Add check for NULL ptr after calling find_cxl_root() | expand

Commit Message

Dave Jiang Jan. 4, 2024, 11 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;