summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlison Schofield <alison.schofield@intel.com>2026-08-21 15:25:14 -0700
committerDave Jiang <dave.jiang@intel.com>2026-08-31 09:41:15 -0700
commitb212e37113f82bfb018e045adfa28dadc3e1bd6d (patch)
tree1258cf0977090128ff5c8cff0b3e55036d9dc64a
parentcee9395acd8043be0644b25c34bfa86623f2b935 (diff)
downloadlinux-next-b212e37113f82bfb018e045adfa28dadc3e1bd6d.tar.gz
linux-next-b212e37113f82bfb018e045adfa28dadc3e1bd6d.zip
cxl/region: Guard against a missing peer mapping
When two endpoints share a dport, both must be mapped by the port. sashiko-bot reports that a missing peer mapping could result in a NULL pointer dereference during region creation. No caller can reach this today. Guard it anyway so a future violation of the mapping requirement fails region creation rather than causing an oops. Reported-by: sashiko-bot@kernel.org Link: https://sashiko.dev/#/patchset/cover.1787255388.git.alison.schofield%40intel.com?part=3 Assisted-by: Claude:claude-opus-5 Signed-off-by: Alison Schofield <alison.schofield@intel.com> Reviewed-by: Richard Cheng <icheng@nvidia.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Link: https://patch.msgid.link/20260821222515.2675707-1-alison.schofield@intel.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
-rw-r--r--drivers/cxl/core/region.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 27e63e6dab7c..75b8092e6dc2 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -1367,7 +1367,8 @@ static int check_last_peer(struct cxl_endpoint_decoder *cxled,
/*
* If this position wants to share a dport with the last endpoint mapped
* then that endpoint, at index 'position - distance', must also be
- * mapped by this dport.
+ * mapped by this dport. An endpoint that this port does not map at all
+ * fails that requirement.
*/
if (pos < distance) {
dev_dbg(&cxlr->dev, "%s:%s: cannot host %s:%s at %d\n",
@@ -1378,7 +1379,7 @@ static int check_last_peer(struct cxl_endpoint_decoder *cxled,
cxled_peer = p->targets[pos - distance];
cxlmd_peer = cxled_to_memdev(cxled_peer);
ep_peer = cxl_ep_load(port, cxlmd_peer);
- if (ep->dport != ep_peer->dport) {
+ if (!ep_peer || ep->dport != ep_peer->dport) {
dev_dbg(&cxlr->dev,
"%s:%s: %s:%s pos %d mismatched peer %s:%s\n",
dev_name(port->uport_dev), dev_name(&port->dev),