Skip to content

Commit 3d8be8b

Browse files
davejiangdjbw
authored andcommitted
cxl: Set cxlmd->endpoint before adding port device
Move setting of cxlmd->endpoint to before calling add_device() on the port device. Otherwise when referencing cxlmd->endpoint in region discovery code that is triggered by the port driver probe function, the endpoint port pointer is not valid. Current code does not hit this issue yet since cxlmd->endpoint is not being referenced during region discovery. However follow on code that does performance calculations will. Tested-by: Wonjae Lee <wj28.lee@samsung.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Tested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/20240308220055.2172956-9-dave.jiang@intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 6ef83c4 commit 3d8be8b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/cxl/core/port.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@ static struct cxl_port *__devm_cxl_add_port(struct device *host,
822822
*/
823823
port->reg_map = cxlds->reg_map;
824824
port->reg_map.host = &port->dev;
825+
cxlmd->endpoint = port;
825826
} else if (parent_dport) {
826827
rc = dev_set_name(dev, "port%d", port->id);
827828
if (rc)
@@ -1374,7 +1375,6 @@ int cxl_endpoint_autoremove(struct cxl_memdev *cxlmd, struct cxl_port *endpoint)
13741375

13751376
get_device(host);
13761377
get_device(&endpoint->dev);
1377-
cxlmd->endpoint = endpoint;
13781378
cxlmd->depth = endpoint->depth;
13791379
return devm_add_action_or_reset(dev, delete_endpoint, cxlmd);
13801380
}

0 commit comments

Comments
 (0)