From: Dan Carpenter Date: Fri, 18 Jul 2025 21:22:40 +0000 (-0500) Subject: cxl/region: Fix an ERR_PTR() vs NULL bug X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49d6e658e758e42aaff8ae5ecdd2d06b29abf53e;p=thirdparty%2Flinux.git cxl/region: Fix an ERR_PTR() vs NULL bug The __cxl_decoder_detach() function is expected to return NULL on error but this error path accidentally returns an error pointer. It could potentially lead to an error pointer dereference in the caller. Change it to return NULL. Fixes: b3a88225519c ("cxl/region: Consolidate cxl_decoder_kill_region() and cxl_region_detach()") Signed-off-by: Dan Carpenter Link: https://patch.msgid.link/7def7da0-326a-410d-8c92-718c8963c0a2@sabinyo.mountain Signed-off-by: Dave Jiang --- diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index e2e9cce13cd2b..e9bf42d916894 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -2108,7 +2108,7 @@ __cxl_decoder_detach(struct cxl_region *cxlr, if (pos >= p->interleave_ways) { dev_dbg(&cxlr->dev, "position %d out of range %d\n", pos, p->interleave_ways); - return ERR_PTR(-ENXIO); + return NULL; } if (!p->targets[pos])