Linux CXL
 help / color / mirror / Atom feed
* [PATCH] cxl/region: Fix null pointer dereference due to pass through decoder commit
@ 2022-08-18 16:42 Jonathan Cameron
  2022-08-18 17:45 ` Verma, Vishal L
  2022-08-19  0:37 ` Dan Williams
  0 siblings, 2 replies; 7+ messages in thread
From: Jonathan Cameron @ 2022-08-18 16:42 UTC (permalink / raw)
  To: linux-cxl, dan.j.williams
  Cc: vishal.l.verma, ira.weiny, alison.schofield, linuxarm, Bobo WL

Not all decoders have a commit callback.

The CXL specification allows a host bridge with a single root port to
have no explicit HDM decoders. Currently we assumes there are none.
As such we create a special pass through decoder instance without
a commit callback.

Prior to this patch, the commit callback was called unconditionally.
Thus a configuration with 1 Host Bridge, 1 Root Port, 1 switch with
multiple downstream ports below which there are multiple CXL type 3
devices results in a situation where committing the region causes
a null pointer dereference.

Reported-by: Bobo WL <lmw.bobo@gmail.com>
Fixes: 176baefb2eb5 ("cxl/hdm: Commit decoder state to hardware")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---

We could fix this with a stub function perhaps as an alternative?

 drivers/cxl/core/region.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 401148016978..c49d9a5f1091 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -174,7 +174,8 @@ static int cxl_region_decode_commit(struct cxl_region *cxlr)
 		     iter = to_cxl_port(iter->dev.parent)) {
 			cxl_rr = cxl_rr_load(iter, cxlr);
 			cxld = cxl_rr->decoder;
-			rc = cxld->commit(cxld);
+			if (cxld->commit)
+				rc = cxld->commit(cxld);
 			if (rc)
 				break;
 		}
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-11 21:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-18 16:42 [PATCH] cxl/region: Fix null pointer dereference due to pass through decoder commit Jonathan Cameron
2022-08-18 17:45 ` Verma, Vishal L
2022-10-11 21:33   ` Dan Williams
2022-08-19  0:37 ` Dan Williams
2022-08-19  8:31   ` Jonathan Cameron
2022-10-10 16:11     ` Jonathan Cameron
2022-10-11 21:30       ` Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox