Skip to content

Commit 20c5e69

Browse files
author
Shubhashree Dhar
committed
drm/msm/sde: Fix NULL pointer dereferencing
Plane count maybe passed to sort function as argument without being checked against NULL value in crtc atomic check and blend setup mixer. Add check to use plane count as argument only when it has a valid value. Change-Id: Ibddd9a630fd5afe55c861975d5fce6985daf1401 Signed-off-by: Shubhashree Dhar <[email protected]>
1 parent a09e96a commit 20c5e69

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/gpu/drm/msm/sde/sde_crtc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,8 @@ static void _sde_crtc_blend_setup_mixer(struct drm_crtc *crtc,
20162016
cnt++;
20172017
}
20182018

2019-
sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
2019+
if (cnt)
2020+
sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
20202021
_sde_crtc_set_src_split_order(crtc, pstates, cnt);
20212022

20222023
if (lm && lm->ops.setup_dim_layer) {
@@ -5278,7 +5279,8 @@ static int sde_crtc_atomic_check(struct drm_crtc *crtc,
52785279
}
52795280

52805281
/* assign mixer stages based on sorted zpos property */
5281-
sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
5282+
if (cnt)
5283+
sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
52825284

52835285
rc = _sde_crtc_excl_dim_layer_check(state, pstates, cnt);
52845286
if (rc)

0 commit comments

Comments
 (0)