From a3fdf9025e37ac4b44be3a823e7a1c076bcc8c71 Mon Sep 17 00:00:00 2001 From: Mahadevan Date: Tue, 17 Nov 2020 19:11:16 +0530 Subject: [PATCH] disp: msm: sde: add check to fix null pointer dereference In pstate_cmp the plane_state structures are accessed without checking it is allocated or not, which leads to null pointer dereference. To fix it NULL check is added. Change-Id: I5982138b396b70979205d87bc9aa260d9501fee0 Signed-off-by: Mahadevan --- msm/sde/sde_crtc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/msm/sde/sde_crtc.c b/msm/sde/sde_crtc.c index f7d531d01c..dddf184c9c 100644 --- a/msm/sde/sde_crtc.c +++ b/msm/sde/sde_crtc.c @@ -1193,6 +1193,9 @@ static int pstate_cmp(const void *a, const void *b) int pa_zpos, pb_zpos; enum sde_layout pa_layout, pb_layout; + if ((!pa || !pa->sde_pstate) || (!pb || !pb->sde_pstate)) + return rc; + pa_zpos = sde_plane_get_property(pa->sde_pstate, PLANE_PROP_ZPOS); pb_zpos = sde_plane_get_property(pb->sde_pstate, PLANE_PROP_ZPOS);