From 1e53604087930e7cf42eee3d42572d0d6f54c86a Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Tue, 7 May 2024 11:44:49 +0100
Subject: [PATCH 1084/1085] drm/vc4: Fix potential null pointer read when
 disabling vblank

vc4_disable_vblank assumed that vc4_encoder was always assigned,
which isn't guaranteed.

If it isn't assigned then disable the interrupt anyway as it's
not connected.

https://github.com/raspberrypi/linux/issues/6146

Fixes: 63c0bcc4b747 ("drm/vc4: Add option to call from crtc to encoder on vblank")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 drivers/gpu/drm/vc4/vc4_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -834,7 +834,7 @@ static void vc4_disable_vblank(struct dr
 	if (!drm_dev_enter(dev, &idx))
 		return;
 
-	if (vc4_encoder->type != VC4_ENCODER_TYPE_DSI0)
+	if (!vc4_encoder || vc4_encoder->type != VC4_ENCODER_TYPE_DSI0)
 		CRTC_WRITE(PV_INTEN, 0);
 
 	drm_dev_exit(idx);
