Skip to content

Commit a70fc4e

Browse files
Robert Richterdjbw
authored andcommitted
cxl/port: Fix NULL pointer access in devm_cxl_add_port()
In devm_cxl_add_port() the port creation may fail and its associated pointer does not contain a valid address. During error message generation this invalid port address is used. Fix that wrong address access. Fixes: f3cd264 ("cxl: Unify debug messages when calling devm_cxl_add_port()") Signed-off-by: Robert Richter <rrichter@amd.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/20230519215436.3394532-1-rrichter@amd.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent e764f12 commit a70fc4e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/cxl/core/port.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -750,11 +750,10 @@ struct cxl_port *devm_cxl_add_port(struct device *host, struct device *uport,
750750

751751
parent_port = parent_dport ? parent_dport->port : NULL;
752752
if (IS_ERR(port)) {
753-
dev_dbg(uport, "Failed to add %s%s%s%s: %ld\n",
754-
dev_name(&port->dev),
755-
parent_port ? " to " : "",
753+
dev_dbg(uport, "Failed to add%s%s%s: %ld\n",
754+
parent_port ? " port to " : "",
756755
parent_port ? dev_name(&parent_port->dev) : "",
757-
parent_port ? "" : " (root port)",
756+
parent_port ? "" : " root port",
758757
PTR_ERR(port));
759758
} else {
760759
dev_dbg(uport, "%s added%s%s%s\n",

0 commit comments

Comments
 (0)