tc358775_parse_dt() stores the remote DSI host node in tc->host_node,
and tc_attach_host() later passes that pointer to
of_find_mipi_dsi_host_by_node().
The parser currently drops the OF node reference immediately after
storing the pointer, leaving the later host lookup to use a node without
an owned reference. Keep the reference for the lifetime of the probed
bridge instead, and put it on probe failures after parse_dt() as well as
on remove.
Fixes: b26975593b17 ("display/drm/bridge: TC358775 DSI/LVDS driver")
Signed-off-by: Zhiqi Zhang <[email protected]>
---
AI assistance disclosure: I found the bug. Codex modified the code.
I reviewed the change.
Build-tested with ARCH=arm64 allmodconfig object builds.
I did not test on hardware.
drivers/gpu/drm/bridge/tc358775.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/bridge/tc358775.c
b/drivers/gpu/drm/bridge/tc358775.c
index 203dc738ec..b2fefc1995 100644
--- a/drivers/gpu/drm/bridge/tc358775.c
+++ b/drivers/gpu/drm/bridge/tc358775.c
@@ -559,8 +559,6 @@ static int tc358775_parse_dt(struct device_node *np, struct
tc_data *tc)
if (!tc->host_node)
return -ENODEV;
- of_node_put(tc->host_node);
-
tc->lvds_link = SINGLE_LINK;
endpoint = of_graph_get_endpoint_by_regs(tc->dev->of_node,
TC358775_LVDS_OUT1, -1);
@@ -681,25 +679,27 @@ static int tc_probe(struct i2c_client *client)
if (IS_ERR(tc->vddio)) {
ret = PTR_ERR(tc->vddio);
dev_err(dev, "vddio-supply not found\n");
- return ret;
+ goto err_put_node;
}
tc->vdd = devm_regulator_get(dev, "vdd-supply");
if (IS_ERR(tc->vdd)) {
ret = PTR_ERR(tc->vdd);
dev_err(dev, "vdd-supply not found\n");
- return ret;
+ goto err_put_node;
}
tc->stby_gpio = devm_gpiod_get_optional(dev, "stby", GPIOD_OUT_HIGH);
- if (IS_ERR(tc->stby_gpio))
- return PTR_ERR(tc->stby_gpio);
+ if (IS_ERR(tc->stby_gpio)) {
+ ret = PTR_ERR(tc->stby_gpio);
+ goto err_put_node;
+ }
tc->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(tc->reset_gpio)) {
ret = PTR_ERR(tc->reset_gpio);
dev_err(dev, "cannot get reset-gpios %d\n", ret);
- return ret;
+ goto err_put_node;
}
tc->bridge.of_node = dev->of_node;
@@ -716,6 +716,8 @@ static int tc_probe(struct i2c_client *client)
err_bridge_remove:
drm_bridge_remove(&tc->bridge);
+err_put_node:
+ of_node_put(tc->host_node);
return ret;
}
@@ -724,6 +726,7 @@ static void tc_remove(struct i2c_client *client)
struct tc_data *tc = i2c_get_clientdata(client);
drm_bridge_remove(&tc->bridge);
+ of_node_put(tc->host_node);
}
static const struct i2c_device_id tc358775_i2c_ids[] = {
--
2.54.0 (Apple Git-157)