]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/bridge: samsung-dsim: samsung_dsim_host_attach: don't use the bridge pointer...
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Fri, 9 Jan 2026 07:31:42 +0000 (08:31 +0100)
committerLuca Ceresoli <luca.ceresoli@bootlin.com>
Tue, 20 Jan 2026 13:53:46 +0000 (14:53 +0100)
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.

Acked-by: Maxime Ripard <mripard@kernel.org>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://patch.msgid.link/20260109-drm-bridge-alloc-getput-drm_of_find_bridge-2-v2-11-8bad3ef90b9f@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
drivers/gpu/drm/bridge/samsung-dsim.c

index 8dd058124e9330b7931ee6593bd4d82e6ecae3a0..afaa63c4d3f730a829aeb78da90b7ed5026b4f2e 100644 (file)
@@ -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 @@ of_find_panel_or_bridge:
        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;
        }