Skip to content

Commit

Permalink
drm/msm/sde: Fix NULL pointer dereferencing
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Shubhashree Dhar committed Aug 5, 2019
1 parent a09e96a commit 20c5e69
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/gpu/drm/msm/sde/sde_crtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,8 @@ static void _sde_crtc_blend_setup_mixer(struct drm_crtc *crtc,
cnt++;
}

sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
if (cnt)
sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
_sde_crtc_set_src_split_order(crtc, pstates, cnt);

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

/* assign mixer stages based on sorted zpos property */
sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
if (cnt)
sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);

rc = _sde_crtc_excl_dim_layer_check(state, pstates, cnt);
if (rc)
Expand Down

1 comment on commit 20c5e69

@stefanhh0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix is as well contained in: 00fcc39 and with cnt > 0 it is even better than what we have here, so the commit should be omitted.

Please sign in to comment.