[PATCH] amdgpu/dc: Avoid dereferencing NULL pointer

S, Shirish Shirish.S at amd.com
Sat Oct 28 01:38:10 UTC 2017


> -----Original Message-----
> From: amd-gfx [mailto:amd-gfx-bounces at lists.freedesktop.org] On Behalf 
> Of Drew Davenport
> Sent: Saturday, October 28, 2017 12:05 AM
> To: amd-gfx at lists.freedesktop.org
> Cc: Deucher, Alexander <Alexander.Deucher at amd.com>; Drew Davenport 
> <ddavenport at chromium.org>
> Subject: [PATCH] amdgpu/dc: Avoid dereferencing NULL pointer
>
> crtc is dereferenced from within drm_atomic_get_new_crtc_state, so 
> check for NULL before initializing new_crtc_state.
>
> Signed-off-by: Drew Davenport <ddavenport at chromium.org>
Reviewed-by: Shirish S <shirish.s at amd.com>
> ---
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index d0ee1b3b8b5c..5a440fadbe18 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -3874,8 +3874,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
>   	/* update planes when needed */
>   	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
>   		struct drm_crtc *crtc = new_plane_state->crtc;
> -		struct drm_crtc_state *new_crtc_state =
> -				drm_atomic_get_new_crtc_state(state, crtc);
> +		struct drm_crtc_state *new_crtc_state;
>   		struct drm_framebuffer *fb = new_plane_state->fb;
>   		bool pflip_needed;
>   		struct dm_plane_state *dm_new_plane_state = 
> to_dm_plane_state(new_plane_state);
> @@ -3885,7 +3884,11 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
>   			continue;
>   		}
>   
> -		if (!fb || !crtc || pcrtc != crtc || !new_crtc_state->active)
> +		if (!fb || !crtc || pcrtc != crtc)
> +			continue;
> +
> +		new_crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
> +		if (!new_crtc_state->active)
>   			continue;
>   
>   		pflip_needed = !state->allow_modeset;



More information about the amd-gfx mailing list