]> Gentwo Git Trees - linux/.git/commitdiff
drm/mediatek: Fix probe memory leak
authorJohan Hovold <johan@kernel.org>
Tue, 23 Sep 2025 15:23:37 +0000 (17:23 +0200)
committerChun-Kuang Hu <chunkuang.hu@kernel.org>
Mon, 17 Nov 2025 15:04:42 +0000 (15:04 +0000)
The Mediatek DRM driver allocates private data for components without a
platform driver but as the lifetime is tied to each component device,
the memory is never freed.

Tie the allocation lifetime to the DRM platform device so that the
memory is released on probe failure (e.g. probe deferral) and when the
driver is unbound.

Fixes: c0d36de868a6 ("drm/mediatek: Move clk info from struct mtk_ddp_comp to sub driver private data")
Cc: stable@vger.kernel.org # 5.12
Cc: CK Hu <ck.hu@mediatek.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://patchwork.kernel.org/project/dri-devel/patch/20250923152340.18234-3-johan@kernel.org/
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
drivers/gpu/drm/mediatek/mtk_ddp_comp.c

index 0264017806adc73000f904bd2692cf9731b211fe..31d67a131c5031c56800b90b6227c8c419f8ff07 100644 (file)
@@ -671,7 +671,7 @@ int mtk_ddp_comp_init(struct device *dev, struct device_node *node, struct mtk_d
            type == MTK_DSI)
                return 0;
 
-       priv = devm_kzalloc(comp->dev, sizeof(*priv), GFP_KERNEL);
+       priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
        if (!priv)
                return -ENOMEM;