[PATCH] drm/meson: fix NULL pointer dereference in meson_drv_bind_master()

From: Rand Deeb

Date: Wed Nov 11 2026 - 04:17:59 EST


If the allocation of priv fails, meson_drv_bind_master() jumps to the
free_drm label, which calls meson_encoder_{dsi,hdmi,cvbs}_remove() with
a NULL priv. These functions dereference priv, so the error path oopses
instead of returning -ENOMEM.

Only the drm device has been allocated at that point, so put it and
return directly.

Found by Linux Verification Center (linuxtesting.org) with SVACE.
Compile tested only.

Fixes: 6a044642988b ("drm/meson: fix unbind path if HDMI fails to bind")
Signed-off-by: Rand Deeb <rand.sec96@xxxxxxxxx>
---
drivers/gpu/drm/meson/meson_drv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
index 38bf2811d..a9b707062 100644
--- a/drivers/gpu/drm/meson/meson_drv.c
+++ b/drivers/gpu/drm/meson/meson_drv.c
@@ -204,8 +204,8 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)

priv = devm_kzalloc_obj(dev, *priv);
if (!priv) {
- ret = -ENOMEM;
- goto free_drm;
+ drm_dev_put(drm);
+ return -ENOMEM;
}
drm->dev_private = priv;
priv->drm = drm;

base-commit: b3dfbde62cf1981c4638939c159dfd087b7a72e9
--
2.39.5