All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] amdgpu/dc: Avoid dereferencing NULL pointer
@ 2017-10-27 18:34 Drew Davenport
       [not found] ` <20171027183446.100536-1-ddavenport-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Davenport @ 2017-10-27 18:34 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Alexander.Deucher-5C7GfCeVMHo, Drew Davenport

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@chromium.org>
---
 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;
-- 
2.15.0.rc2.357.g7e34df9404-goog

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] amdgpu/dc: Avoid dereferencing NULL pointer
       [not found] ` <20171027183446.100536-1-ddavenport-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2017-10-27 19:29   ` Harry Wentland
  0 siblings, 0 replies; 3+ messages in thread
From: Harry Wentland @ 2017-10-27 19:29 UTC (permalink / raw)
  To: Drew Davenport, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Alexander.Deucher-5C7GfCeVMHo, Li, Sun peng

On 2017-10-27 02:34 PM, Drew Davenport wrote:
> 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@chromium.org>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  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;
> 
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] amdgpu/dc: Avoid dereferencing NULL pointer
@ 2017-10-28  1:38 S, Shirish
  0 siblings, 0 replies; 3+ messages in thread
From: S, Shirish @ 2017-10-28  1:38 UTC (permalink / raw)
  To: Drew Davenport, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Deucher, Alexander

> -----Original Message-----
> From: amd-gfx [mailto:amd-gfx-bounces@lists.freedesktop.org] On Behalf 
> Of Drew Davenport
> Sent: Saturday, October 28, 2017 12:05 AM
> To: amd-gfx@lists.freedesktop.org
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Drew Davenport 
> <ddavenport@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@chromium.org>
Reviewed-by: Shirish S <shirish.s@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;

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-28  1:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-27 18:34 [PATCH] amdgpu/dc: Avoid dereferencing NULL pointer Drew Davenport
     [not found] ` <20171027183446.100536-1-ddavenport-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2017-10-27 19:29   ` Harry Wentland
2017-10-28  1:38 S, Shirish

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.