• Nicholas Kazlauskas's avatar
    drm/amd/display: Fix overflow/truncation from strncpy. · 090afc1e
    Nicholas Kazlauskas authored
    [Why]
    
    New GCC warnings for stringop-truncation and stringop-overflow help
    catch common misuse of strncpy. This patch suppresses these warnings
    by fixing bugs identified by them.
    
    [How]
    
    Since the parameter passed for name in amdpgu_dm_create_common_mode has
    no fixed length, if the string is >= DRM_DISPLAY_MODE_LEN then
    mode->name will not be null-terminated.
    
    The truncation in fill_audio_info won't actually occur (and the string
    will be null-terminated since the buffer is initialized to zero), but
    the warning can be suppressed by using the proper buffer size.
    
    This patch fixes both issues by using the real size for the buffer and
    making use of strscpy (which always terminates).
    Signed-off-by: default avatarNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
    Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
    Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
    090afc1e
amdgpu_dm.c 154 KB