From e529e5c9227cfd808d59e3c77ff050a5d5986c27 Mon Sep 17 00:00:00 2001 From: Mikel Rychliski Date: Sun, 7 Apr 2024 19:52:26 +0000 Subject: [PATCH] drm: sun4i: hdmi: Fix oops when disabling output If the display does not indicate audio support in the EDID, hdmi->hdmi_audio will be NULL. In this case, we avoid setting up audio output, however we were still attempting to tear it down on disable. This could lead to a null pointer exception when disabling the output. Fix the issue by using the same check on tear down as we do on create. Signed-off-by: Mikel Rychliski --- drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c index 58c99fcc7e54..4ad5da606a3e 100644 --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c @@ -91,7 +91,8 @@ static void sun4i_hdmi_disable(struct drm_encoder *encoder) DRM_DEBUG_DRIVER("Disabling the HDMI Output\n"); #ifdef CONFIG_DRM_SUN4I_HDMI_AUDIO - sun4i_hdmi_audio_destroy(hdmi); + if (hdmi->hdmi_audio) + sun4i_hdmi_audio_destroy(hdmi); #endif val = readl(hdmi->base + SUN4I_HDMI_VID_CTRL_REG);