[4/6] drm/amd/amdgpu: Check stream in amdgpu_dm_commit_planes

Submitted by Ernst Sjöstrand on June 24, 2019, 3:15 p.m.

Details

Message ID 20190624151544.13934-4-ernstp@gmail.com
State Accepted
Commit ed9656fbc8b5b13a2350d9a7eb70f1b8d55e5803
Headers show
Series "Series without cover letter" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Ernst Sjöstrand June 24, 2019, 3:15 p.m.
Reported by smatch:
amdgpu_dm.c:5637 amdgpu_dm_commit_planes() error: we previously assumed 'acrtc_state->stream' could be null
This seems to be checked for null pretty consistently elsewhere.

Signed-off-by: Ernst Sjöstrand <ernstp@gmail.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

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 58d7bbc5ada7..360b31a5c028 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -5669,7 +5669,8 @@  static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 	}
 
 	/* Update the planes if changed or disable if we don't have any. */
-	if (planes_count || acrtc_state->active_planes == 0) {
+	if ((planes_count || acrtc_state->active_planes == 0) &&
+		acrtc_state->stream) {
 		if (new_pcrtc_state->mode_changed) {
 			bundle->stream_update.src = acrtc_state->stream->src;
 			bundle->stream_update.dst = acrtc_state->stream->dst;

Comments

On 6/24/19 11:15 AM, Ernst Sjöstrand wrote:
> Reported by smatch:

> amdgpu_dm.c:5637 amdgpu_dm_commit_planes() error: we previously assumed 'acrtc_state->stream' could be null

> This seems to be checked for null pretty consistently elsewhere.

> 

> Signed-off-by: Ernst Sjöstrand <ernstp@gmail.com>


This is already reviewed and merged, but this NULL check is actually 
unnecessary. This function doesn't run in the new_crtc_state->stream is 
NULL.

Technically the behavior does change inside 
dc_commit_updates_for_stream. We don't actually deference the stream 
anywhere as far as I can tell, but we do an prepare/optimize bandwidth 
and a state swap. The missing state swap would matter here, but once 
again, we don't actually run this function at all.

All these checks should probably just be dropped.

Nicholas Kazlauskas

> ---

>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-

>   1 file changed, 2 insertions(+), 1 deletion(-)

> 

> 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 58d7bbc5ada7..360b31a5c028 100644

> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

> @@ -5669,7 +5669,8 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,

>   	}

>   

>   	/* Update the planes if changed or disable if we don't have any. */

> -	if (planes_count || acrtc_state->active_planes == 0) {

> +	if ((planes_count || acrtc_state->active_planes == 0) &&

> +		acrtc_state->stream) {

>   		if (new_pcrtc_state->mode_changed) {

>   			bundle->stream_update.src = acrtc_state->stream->src;

>   			bundle->stream_update.dst = acrtc_state->stream->dst;

>