Re: [PATCH] drm/amd/display: Fix NULL dereference when preferred_mode is NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/29/18 10:17 AM, Nicholas Kazlauskas wrote:
> [Why]
> When preferred_mode is NULL a null pointer dereference can occur
> when trying to get the preferred refresh in create_stream_for_sink.
> 
> [How]
> Only query preferred_refresh when preferred_mode is not NULL. Consider
> preferred_refresh if it is since it's only being used to compare to
> the previous value.
> 
> Fixes: b333730d126e ("drm/amd/display: Fix Scaling (RMX_*) for DC driver")
> 
> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@xxxxxxx>
> ---
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 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 ce00e56814ed..478fa810438e 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -2848,7 +2848,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
>   	bool native_mode_found = false;
>   	bool scale = dm_state ? (dm_state->scaling != RMX_OFF) : false;
>   	int mode_refresh;
> -	int preferred_refresh;
> +	int preferred_refresh = 0;
>   
>   	struct dc_sink *sink = NULL;
>   	if (aconnector == NULL) {
> @@ -2907,7 +2907,8 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
>   	if (!dm_state)
>   		drm_mode_set_crtcinfo(&mode, 0);
>   
> -	preferred_refresh = drm_mode_vrefresh(preferred_mode);
> +	if (preferred_mode)
> +		preferred_refresh = drm_mode_vrefresh(preferred_mode);
>   
>   	/*
>   	* If scaling is enabled and refresh rate didn't change
> 

Actually, this is the same patch as "drm/amd/display: Fix NULL ptr when 
calculating refresh rate" from Jerry.

https://patchwork.freedesktop.org/patch/264242/

This can be ignored.

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




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux