]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/bridge: ti-sn65dsi83: use dynamic lifetime management
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Wed, 26 Mar 2025 17:47:38 +0000 (18:47 +0100)
committerLouis Chauvet <louis.chauvet@bootlin.com>
Mon, 7 Apr 2025 09:38:05 +0000 (11:38 +0200)
Allow this bridge to be removable without dangling pointers and
use-after-free, together with proper use of drm_bridge_get() and _put() by
consumers.

Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250326-drm-bridge-refcount-v9-4-5e0661fe1f84@bootlin.com
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
drivers/gpu/drm/bridge/ti-sn65dsi83.c

index 53cc4cfb0c884f6a410e3df2c4df4572f89c0768..033c44326552ab167d4e8d9b74957c585e4c6fb7 100644 (file)
@@ -941,9 +941,9 @@ static int sn65dsi83_probe(struct i2c_client *client)
        struct sn65dsi83 *ctx;
        int ret;
 
-       ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
-       if (!ctx)
-               return -ENOMEM;
+       ctx = devm_drm_bridge_alloc(dev, struct sn65dsi83, bridge, &sn65dsi83_funcs);
+       if (IS_ERR(ctx))
+               return PTR_ERR(ctx);
 
        ctx->dev = dev;
        INIT_WORK(&ctx->reset_work, sn65dsi83_reset_work);
@@ -983,7 +983,6 @@ static int sn65dsi83_probe(struct i2c_client *client)
        dev_set_drvdata(dev, ctx);
        i2c_set_clientdata(client, ctx);
 
-       ctx->bridge.funcs = &sn65dsi83_funcs;
        ctx->bridge.of_node = dev->of_node;
        ctx->bridge.pre_enable_prev_first = true;
        ctx->bridge.type = DRM_MODE_CONNECTOR_LVDS;