[Intel-gfx] [PATCH] drm/i915: Fix possible NULL pointer dereferences in i9xx_update_wm()

Harish Chegondi harish.chegondi at intel.com
Thu Dec 16 23:21:24 UTC 2021


Check return pointer from intel_crtc_for_plane() before dereferencing
it, as it can be NULL.

Cc: Jani Nikula <jani.nikula at intel.com>
Cc: Caz Yokoyama <caz.yokoyama at intel.com>
Cc: Radhakrishna Sripada <radhakrishna.sripada at intel.com>
Signed-off-by: Harish Chegondi <harish.chegondi at intel.com>
---
 drivers/gpu/drm/i915/intel_pm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index bdf97a8c9ef3..c7a4d8d971d7 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -2373,7 +2373,7 @@ static void i9xx_update_wm(struct drm_i915_private *dev_priv)
 	else
 		fifo_size = i9xx_get_fifo_size(dev_priv, PLANE_A);
 	crtc = intel_crtc_for_plane(dev_priv, PLANE_A);
-	if (intel_crtc_active(crtc)) {
+	if (crtc && intel_crtc_active(crtc)) {
 		const struct drm_display_mode *pipe_mode =
 			&crtc->config->hw.pipe_mode;
 		const struct drm_framebuffer *fb =
@@ -2403,7 +2403,7 @@ static void i9xx_update_wm(struct drm_i915_private *dev_priv)
 	else
 		fifo_size = i9xx_get_fifo_size(dev_priv, PLANE_B);
 	crtc = intel_crtc_for_plane(dev_priv, PLANE_B);
-	if (intel_crtc_active(crtc)) {
+	if (crtc && intel_crtc_active(crtc)) {
 		const struct drm_display_mode *pipe_mode =
 			&crtc->config->hw.pipe_mode;
 		const struct drm_framebuffer *fb =
-- 
2.31.1



More information about the Intel-gfx mailing list