mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Harry Wentland <harry.wentland@amd.com>
To: "Gustavo A. R. Silva" <garsilva@embeddedor.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"David Airlie" <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/amd/display: Fix potential NULL pointer dereferences in amdgpu_dm_atomic_commit_tail
Date: Mon, 27 Nov 2017 14:23:12 -0500	[thread overview]
Message-ID: <3ff97f37-946a-a795-e57c-6d835e93be21@amd.com> (raw)
In-Reply-To: <20171127145700.GA18395@embeddedor.com>

On 2017-11-27 09:57 AM, Gustavo A. R. Silva wrote:
> dm_new_crtc_state->stream and disconnected_acrtc are being dereferenced
> before they are null checked, hence there is a potential null pointer
> dereference.
> 
> Fix this by null checking such pointers before they are dereferenced.
> 
> Addresses-Coverity-ID: 1423745 ("Dereference before null check")
> Addresses-Coverity-ID: 1423833 ("Dereference before null check")
> Fixes: e7b07ceef2a6 ("drm/amd/display: Merge amdgpu_dm_types and amdgpu_dm")
> Fixes: 54d765752467 ("drm/amd/display: Unify amdgpu_dm state variable namings.")
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 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 889ed24..3bdd137 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -4190,6 +4190,9 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
>  
>  		dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
>  
> +		if (!dm_new_crtc_state->stream)
> +			continue;
> +
>  		update_stream_scaling_settings(&dm_new_con_state->base.crtc->mode,
>  				dm_new_con_state, (struct dc_stream_state *)dm_new_crtc_state->stream);
>  
> @@ -4197,9 +4200,6 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
>  		WARN_ON(!status);
>  		WARN_ON(!status->plane_count);
>  
> -		if (!dm_new_crtc_state->stream)
> -			continue;
> -
>  		/*TODO How it works with MPO ?*/
>  		if (!dc_commit_planes_to_stream(
>  				dm->dc,
> @@ -4332,9 +4332,11 @@ void dm_restore_drm_connector_state(struct drm_device *dev,
>  		return;
>  
>  	disconnected_acrtc = to_amdgpu_crtc(connector->encoder->crtc);
> -	acrtc_state = to_dm_crtc_state(disconnected_acrtc->base.state);
> +	if (!disconnected_acrtc)
> +		return;
>  
> -	if (!disconnected_acrtc || !acrtc_state->stream)
> +	acrtc_state = to_dm_crtc_state(disconnected_acrtc->base.state);
> +	if (!acrtc_state->stream)
>  		return;

This part is already in https://lists.freedesktop.org/archives/amd-gfx/2017-November/016389.html on its way to be merged.

The rest of the patch is
Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

>  
>  	/*
> 

  reply	other threads:[~2017-11-27 19:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-27 14:57 Gustavo A. R. Silva
2017-11-27 19:23 ` Harry Wentland [this message]
2017-11-28 14:33 ` Andrey Grodzovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3ff97f37-946a-a795-e57c-6d835e93be21@amd.com \
    --to=harry.wentland@amd.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=garsilva@embeddedor.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome