]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/i915/ddi: only call shutdown hooks for valid encoders
authorJani Nikula <jani.nikula@intel.com>
Mon, 30 Dec 2024 14:14:45 +0000 (16:14 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 10:14:11 +0000 (12:14 +0200)
commit 60a43ecbd59decb77b31c09a73f09e1d4f4d1c4c upstream.

DDI might be HDMI or DP only, leaving the other encoder
uninitialized. Calling the shutdown hook on an uninitialized encoder may
lead to a NULL pointer dereference. Check the encoder types (and thus
validity via the DP output_reg or HDMI hdmi_reg checks) before calling
the hooks.

Reported-and-tested-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Closes: https://lore.kernel.org/r/20241031105145.2140590-1-senozhatsky@chromium.org
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/8b197c50e7f3be2bbc07e3935b21e919815015d5.1735568047.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/i915/display/intel_ddi.c

index 9e42f0836989e7a81e490a4708391371f4c85f6f..5b24460c01341749dbd866ea1f871cdd093a83eb 100644 (file)
@@ -4798,8 +4798,10 @@ static void intel_ddi_tc_encoder_suspend_complete(struct intel_encoder *encoder)
 
 static void intel_ddi_encoder_shutdown(struct intel_encoder *encoder)
 {
-       intel_dp_encoder_shutdown(encoder);
-       intel_hdmi_encoder_shutdown(encoder);
+       if (intel_encoder_is_dp(encoder))
+               intel_dp_encoder_shutdown(encoder);
+       if (intel_encoder_is_hdmi(encoder))
+               intel_hdmi_encoder_shutdown(encoder);
 }
 
 static void intel_ddi_tc_encoder_shutdown_complete(struct intel_encoder *encoder)