struct cxl_nvdimm_bridge *cxl_find_nvdimm_bridge(struct cxl_memdev *cxlmd)
 {
-       struct cxl_root *cxl_root = find_cxl_root(cxlmd->endpoint);
-       struct cxl_port *port;
+       struct cxl_root *cxl_root __free(put_cxl_root) =
+               find_cxl_root(cxlmd->endpoint);
        struct device *dev;
 
        if (!cxl_root)
                return NULL;
 
-       port = &cxl_root->port;
-       dev = device_find_child(&port->dev, NULL, match_nvdimm_bridge);
-       put_device(&port->dev);
+       dev = device_find_child(&cxl_root->port.dev, NULL, match_nvdimm_bridge);
 
        if (!dev)
                return NULL;