drm/msm/disp/dpu: fix early dereference of physical encoder
authorJeykumar Sankaran <jsanka@codeaurora.org>
Wed, 8 Aug 2018 02:56:51 +0000 (19:56 -0700)
committerRob Clark <robdclark@gmail.com>
Fri, 10 Aug 2018 22:49:18 +0000 (18:49 -0400)
This change validates the physical encoder before it
is dereferenced.

Signed-off-by: Jeykumar Sankaran <jsanka@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c

index 0922d3536412ea61078283172b717aebdd9715ec..1b4de3486ef9e14fa8b172de29d68db2df41e802 100644 (file)
@@ -2444,6 +2444,8 @@ int dpu_encoder_wait_for_event(struct drm_encoder *drm_enc,
 
        for (i = 0; i < dpu_enc->num_phys_encs; i++) {
                struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i];
+               if (!phys)
+                       continue;
 
                switch (event) {
                case MSM_ENC_COMMIT_DONE:
@@ -2461,7 +2463,7 @@ int dpu_encoder_wait_for_event(struct drm_encoder *drm_enc,
                        return -EINVAL;
                };
 
-               if (phys && fn_wait) {
+               if (fn_wait) {
                        DPU_ATRACE_BEGIN("wait_for_completion_event");
                        ret = fn_wait(phys);
                        DPU_ATRACE_END("wait_for_completion_event");