Browse Source

drm/amd/display: fix NULL pointer in dm_commit_surfaces

Check if adding surface is failed to prevent NULL pointer deref.

Signed-off-by: Jerry Zuo <Jerry.Zuo@amd.com>
Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Jerry Zuo 8 years ago
parent
commit
afdbd4ccfd
1 changed files with 4 additions and 0 deletions
  1. 4 0
      drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c

+ 4 - 0
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c

@@ -2411,6 +2411,10 @@ static void amdgpu_dm_commit_surfaces(struct drm_atomic_state *state,
 			if (crtc == pcrtc) {
 				add_surface(dm->dc, crtc, plane,
 					    &dc_surfaces_constructed[planes_count]);
+				if (dc_surfaces_constructed[planes_count] == NULL) {
+					dm_error("%s: Failed to add surface!\n", __func__);
+					continue;
+				}
 				dc_stream_attach = acrtc_attach->stream;
 				planes_count++;
 			}