In preparation to handle refcounting of the out_bridge, we need to ensure the out_bridge pointer contains either a valid bridge pointer or NULL, not an ERR_PTR. Otherwise calls such as drm_bridge_get/put() would try to redeference an ERR_PTR.
Stop using IS_ERR(next_bridge) as an indication of an error, and instead use the 'ret' integer. No functional change. Signed-off-by: Luca Ceresoli <[email protected]> --- drivers/gpu/drm/bridge/samsung-dsim.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index b3003aa49dc3..d6ef64e68623 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -1891,7 +1891,7 @@ static int samsung_dsim_host_attach(struct mipi_dsi_host *host, struct device_node *np = dev->of_node; struct device_node *remote; struct drm_panel *panel; - int ret; + int ret = 0; /* * Devices can also be child nodes when we also control that device @@ -1926,16 +1926,17 @@ static int samsung_dsim_host_attach(struct mipi_dsi_host *host, panel = of_drm_find_panel(remote); if (!IS_ERR(panel)) { next_bridge = devm_drm_panel_bridge_add(dev, panel); + if (IS_ERR(next_bridge)) + ret = PTR_ERR(next_bridge); } else { next_bridge = of_drm_find_bridge(remote); if (!next_bridge) - next_bridge = ERR_PTR(-EINVAL); + ret = -EINVAL; } of_node_put(remote); - if (IS_ERR(next_bridge)) { - ret = PTR_ERR(next_bridge); + if (ret) { DRM_DEV_ERROR(dev, "failed to find the bridge: %d\n", ret); return ret; } -- 2.52.0
