All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] cxl/region: Fix use-after-free in find_pos_and_ways() error path
@ 2026-07-21 17:37 Alison Schofield
  2026-07-21 17:37 ` [PATCH v2 2/2] cxl/region: Use __free(put_device) in find_pos_and_ways() Alison Schofield
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Alison Schofield @ 2026-07-21 17:37 UTC (permalink / raw)
  To: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
	Vishal Verma, Ira Weiny, Dan Williams, Li Ming
  Cc: linux-cxl

The error path releases its reference to a switch decoder before
logging an error that includes the decoder name. If the released
reference is the last one, the decoder can be freed before the error
message accesses its name.

Drop  the reference after the error is reported.

Fixes: d90acdf49e18 ("cxl/region: Add a dev_err() on missing target list entries")
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---

No changes in v2.
Reposted in series w the __free change in patch 2/2



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

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 1e211542b6b6..c86dd9d55e93 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -1938,8 +1938,6 @@ static int find_pos_and_ways(struct cxl_port *port, struct range *range,
 			break;
 		}
 	}
-	put_device(dev);
-
 	if (rc)
 		dev_err(port->uport_dev,
 			"failed to find %s:%s in target list of %s\n",
@@ -1947,6 +1945,8 @@ static int find_pos_and_ways(struct cxl_port *port, struct range *range,
 			dev_name(port->parent_dport->dport_dev),
 			dev_name(&cxlsd->cxld.dev));
 
+	put_device(dev);
+
 	return rc;
 }
 

base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
-- 
2.37.3


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

end of thread, other threads:[~2026-07-24 21:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-21 17:37 [PATCH v2 1/2] cxl/region: Fix use-after-free in find_pos_and_ways() error path Alison Schofield
2026-07-21 17:37 ` [PATCH v2 2/2] cxl/region: Use __free(put_device) in find_pos_and_ways() Alison Schofield
2026-07-21 23:56   ` Jonathan Cameron
2026-07-24 21:57     ` Alison Schofield
2026-07-22  5:25   ` Li Ming
2026-07-21 17:50 ` [PATCH v2 1/2] cxl/region: Fix use-after-free in find_pos_and_ways() error path sashiko-bot
2026-07-24 21:40   ` Alison Schofield
2026-07-21 23:53 ` Jonathan Cameron
2026-07-24 21:54   ` Alison Schofield
2026-07-22  5:24 ` Li Ming

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.