Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Medium] drm/mediatek: device node reference leak in mtk_drm_probe()
  [1]
--

commit ca36688b98d58f438e7795c4737e318297cc995d
Author: Yige Jiang <[email protected]>

drm/mediatek: Keep the mutex node reference across deferred binds

This commit removes the of_node_put(private->mutex_node) call from the
-EPROBE_DEFER error path in mtk_drm_bind() so the reference acquired in
mtk_drm_probe() is retained until probe failure or mtk_drm_remove().

> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
> b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index dc8e3e917dd77..64c912ba95899 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -630,7 +630,6 @@ static int mtk_drm_bind(struct device *dev)
>       if (!pdev) {
>               dev_err(dev, "Waiting for disp-mutex device %pOF\n",
>                       private->mutex_node);
> -             of_node_put(private->mutex_node);
>               return -EPROBE_DEFER;
>       }

[Severity: Medium]
This problem wasn't introduced by this patch, but can mtk_drm_probe() leak
a device_node reference in private->mutex_node [1]?

drivers/gpu/drm/mediatek/mtk_drm_drv.c:mtk_drm_probe() {
        ...
        for_each_child_of_node(phandle->parent, node) {
                ...
                if (comp_type == MTK_DISP_MUTEX) {
                        int id;

                        id = of_alias_get_id(node, "mutex");
                        if (id < 0 || id == private->data->mmsys_id) {
                                private->mutex_node = of_node_get(node);
                                dev_dbg(dev, "get mutex for mmsys %d", 
private->data->mmsys_id);
                        }
                        continue;
                }
        ...
}

If the loop matches more than one MTK_DISP_MUTEX child node (for instance,
when multiple mutex nodes have no "mutex" alias), private->mutex_node is
overwritten without calling of_node_put() on the previously acquired node,
leaking its reference.

[1] https://sashiko.dev/#/bug/linux-6030c65d-4659-4fa7-8aa2-9eff923ac68e

-- 
Sashiko AI review · 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to