drm/vc4: crtc: Add null pointer error handling 02/244402/1
authorHoegeun Kwon <hoegeun.kwon@samsung.com>
Fri, 18 Sep 2020 06:54:43 +0000 (15:54 +0900)
committerHoegeun Kwon <hoegeun.kwon@samsung.com>
Fri, 18 Sep 2020 07:08:03 +0000 (16:08 +0900)
Crash occurs when vc4_encoder is null. Add null error handling

  Unable to handle kernel NULL pointer dereference at virtual address 0000000000000090
  Mem abort info:
    ESR = 0x96000005
    EC = 0x25: DABT (current EL), IL = 32 bits
    SET = 0, FnV = 0
    EA = 0, S1PTW = 0
  Data abort info:
    ISV = 0, ISS = 0x00000005
    CM = 0, WnR = 0
  user pgtable: 4k pages, 39-bit VAs, pgdp=00000000f2a96000
  [0000000000000090] pgd=0000000000000000, pud=0000000000000000
  Internal error: Oops: 96000005 [#1] PREEMPT SMP
  Modules linked in: brcmfmac joydev brcmutil rpivid_mem
  CPU: 0 PID: 32 Comm: kworker/0:1 Not tainted 5.4.50-v8+ #414
  Hardware name: Raspberry Pi 4 Model B (DT)
  Workqueue: events output_poll_execute
  pstate: 80000005 (Nzcv daif -PAN -UAO)
  pc : vc4_crtc_atomic_disable+0x150/0x2e8
  lr : vc4_crtc_atomic_disable+0x50/0x2e8
  ...
  Call trace:
   vc4_crtc_atomic_disable+0x150/0x2e8
   drm_atomic_helper_commit_modeset_disables+0x344/0x410
   vc4_atomic_complete_commit+0xd4/0x530
   vc4_atomic_commit+0xf4/0x190
   drm_atomic_commit+0x54/0x60
   ...

Change-Id: Ib3271bb3c8318079fe5815711f89a217e835adc6
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
drivers/gpu/drm/vc4/vc4_crtc.c

index 129cf90..f8fa076 100644 (file)
@@ -508,7 +508,7 @@ static void vc4_crtc_atomic_disable(struct drm_crtc *crtc,
        ret = wait_for(!(CRTC_READ(PV_V_CONTROL) & PV_VCONTROL_VIDEN), 1);
        WARN_ONCE(ret, "Timeout waiting for !PV_VCONTROL_VIDEN\n");
 
-       if (vc4_encoder->post_crtc_disable)
+       if (vc4_encoder && vc4_encoder->post_crtc_disable)
                vc4_encoder->post_crtc_disable(encoder);
 
        CRTC_WRITE(PV_CONTROL, CRTC_READ(PV_CONTROL) & ~PV_CONTROL_EN);
@@ -536,7 +536,7 @@ static void vc4_crtc_atomic_disable(struct drm_crtc *crtc,
                      (SCALER_DISPSTATX_FULL | SCALER_DISPSTATX_EMPTY)) !=
                     SCALER_DISPSTATX_EMPTY);
 
-       if (vc4_encoder->post_crtc_powerdown)
+       if (vc4_encoder && vc4_encoder->post_crtc_powerdown)
                vc4_encoder->post_crtc_powerdown(encoder);
 
        /*