[PATCH 3/3] amdgpu/dc: Fix missing null checks in amdgpu_dm.c

Christian König ckoenig.leichtzumerken at gmail.com
Tue Nov 7 10:33:23 UTC 2017


Am 07.11.2017 um 00:54 schrieb Ernst Sjöstrand:
>  From smatch:
> error: we previously assumed X could be null
>
> Signed-off-by: Ernst Sjöstrand <ernstp at gmail.com>
> ---
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 15 +++++++++++----
>   1 file changed, 11 insertions(+), 4 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 2301589e4cc3..d036178c2241 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -432,8 +432,10 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
>   
>   	if (adev->dm.dc)
>   		DRM_INFO("Display Core initialized!\n");
> -	else
> +	else {
>   		DRM_INFO("Display Core failed to initialize!\n");
> +		goto error;
> +	}

One minor coding style nit pick here: When one part of an if/else has {} 
the other one should have that as well. E.g. if { ... } else { ... }.

Apart from that thanks a lot for the help, the whole series is Acked-by: 
Christian König <christian.koenig at amd.com>.

Regards,
Christian.

>   
>   	INIT_WORK(&adev->dm.mst_hotplug_work, hotplug_notify_work_func);
>   
> @@ -2263,7 +2265,7 @@ decide_crtc_timing_for_drm_display_mode(struct drm_display_mode *drm_mode,
>   	}
>   }
>   
> -static void create_fake_sink(struct amdgpu_dm_connector *aconnector)
> +static int create_fake_sink(struct amdgpu_dm_connector *aconnector)
>   {
>   	struct dc_sink *sink = NULL;
>   	struct dc_sink_init_data sink_init_data = { 0 };
> @@ -2272,14 +2274,18 @@ static void create_fake_sink(struct amdgpu_dm_connector *aconnector)
>   	sink_init_data.sink_signal = aconnector->dc_link->connector_signal;
>   
>   	sink = dc_sink_create(&sink_init_data);
> -	if (!sink)
> +	if (!sink) {
>   		DRM_ERROR("Failed to create sink!\n");
> +		return -1;
> +	}
>   
>   	sink->sink_signal = SIGNAL_TYPE_VIRTUAL;
>   	aconnector->fake_enable = true;
>   
>   	aconnector->dc_sink = sink;
>   	aconnector->dc_link->local_sink = sink;
> +
> +	return 0;
>   }
>   
>   static struct dc_stream_state *
> @@ -2313,7 +2319,8 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
>   		if (aconnector->mst_port)
>   			goto stream_create_fail;
>   
> -		create_fake_sink(aconnector);
> +		if (create_fake_sink(aconnector))
> +			goto stream_create_fail;
>   	}
>   
>   	stream = dc_create_stream_for_sink(aconnector->dc_sink);




More information about the amd-gfx mailing list