Skip to content

Commit f2c8bbb

Browse files
committed
Merge tag 'mediatek-drm-fixes-20250910' of https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux into drm-fixes
Mediatek DRM Fixes - 20250910 1. fix potential OF node use-after-free Signed-off-by: Dave Airlie <[email protected]> From: Chun-Kuang Hu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
2 parents 1d00adb + 9ba2556 commit f2c8bbb

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

drivers/gpu/drm/mediatek/mtk_drm_drv.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -387,19 +387,21 @@ static bool mtk_drm_get_all_drm_priv(struct device *dev)
387387

388388
of_id = of_match_node(mtk_drm_of_ids, node);
389389
if (!of_id)
390-
goto next_put_node;
390+
continue;
391391

392392
pdev = of_find_device_by_node(node);
393393
if (!pdev)
394-
goto next_put_node;
394+
continue;
395395

396396
drm_dev = device_find_child(&pdev->dev, NULL, mtk_drm_match);
397+
put_device(&pdev->dev);
397398
if (!drm_dev)
398-
goto next_put_device_pdev_dev;
399+
continue;
399400

400401
temp_drm_priv = dev_get_drvdata(drm_dev);
402+
put_device(drm_dev);
401403
if (!temp_drm_priv)
402-
goto next_put_device_drm_dev;
404+
continue;
403405

404406
if (temp_drm_priv->data->main_len)
405407
all_drm_priv[CRTC_MAIN] = temp_drm_priv;
@@ -411,17 +413,10 @@ static bool mtk_drm_get_all_drm_priv(struct device *dev)
411413
if (temp_drm_priv->mtk_drm_bound)
412414
cnt++;
413415

414-
next_put_device_drm_dev:
415-
put_device(drm_dev);
416-
417-
next_put_device_pdev_dev:
418-
put_device(&pdev->dev);
419-
420-
next_put_node:
421-
of_node_put(node);
422-
423-
if (cnt == MAX_CRTC)
416+
if (cnt == MAX_CRTC) {
417+
of_node_put(node);
424418
break;
419+
}
425420
}
426421

427422
if (drm_priv->data->mmsys_dev_num == cnt) {

0 commit comments

Comments
 (0)