[PATCH] amd/display: Fix potential null dereference in dce_calcs.c

Harry Wentland harry.wentland at amd.com
Wed Nov 8 21:19:26 UTC 2017


On 2017-11-08 03:54 PM, Deucher, Alexander wrote:
>> -----Original Message-----
>> From: amd-gfx [mailto:amd-gfx-bounces at lists.freedesktop.org] On Behalf
>> Of Ernst Sjöstrand
>> Sent: Wednesday, November 08, 2017 3:17 PM
>> To: amd-gfx at lists.freedesktop.org
>> Subject: [PATCH] amd/display: Fix potential null dereference in dce_calcs.c
>>
>> Reported by smatch:
>> bw_calcs() error: potential null dereference 'data'
>>
>> Signed-off-by: Ernst Sjöstrand <ernstp at gmail.com>
>> ---
>>  drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
>> b/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
>> index 4f8a95368ffc..64a885195208 100644
>> --- a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
>> +++ b/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
>> @@ -2794,6 +2794,10 @@ bool bw_calcs(struct dc_context *ctx,
>>  {
>>  	struct bw_calcs_data *data = kzalloc(sizeof(struct bw_calcs_data),
>>  					     GFP_KERNEL);
>> +	if (!data) {
>> +		DRM_ERROR("Failed to allocate bw_calcs_data\n");
> 
> I think we are trying to keep DRM specifics out of dc as much as possible so drop the error message and just return false.
> 

Alternatively use DC_ERROR() to log, just like you would with DRM_ERROR.

Note that if you trace it you'll go down the rabbit hole that's the DC logger. It's still on our list to clean up and route more directly to kernel logging functionality. A task for that is in amd/display/TODO.

Thanks for the patch.

Harry

> Thanks!
> 
> Alex
> 
>> +		return false;
>> +	}
>>
>>  	populate_initial_data(pipe, pipe_count, data);
>>
>> --
>> 2.14.1
>>
>> _______________________________________________
>> amd-gfx mailing list
>> amd-gfx at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
> 


More information about the amd-gfx mailing list