• Pratap Nirujogi's avatar
    drm/amd/amdgpu: Fix 'snprintf' output truncation warning · 7c2d3112
    Pratap Nirujogi authored
    snprintf can truncate the output fw filename if the isp ucode_prefix
    exceeds 29 characters. Knowing ISP ucode_prefix is in the format
    isp_x_x_x, limiting the size of ucode_prefix[] to 10 characters
    to fix the warning.
    
    Fixes the below warning:
    
       drivers/gpu/drm/amd/amdgpu/amdgpu_isp.c: In function 'isp_early_init':
       drivers/gpu/drm/amd/amdgpu/amdgpu_isp.c:192:58: warning: 'snprintf'
       output may be truncated before the last format character
       [-Wformat-truncation=]
         192 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s.bin", ucode_prefix);
             |                                                          ^
       In function 'isp_load_fw_by_psp',
           inlined from 'isp_early_init' at drivers/gpu/drm/amd/amdgpu/amdgpu_isp.c:218:8:
       drivers/gpu/drm/amd/amdgpu/amdgpu_isp.c:192:9: note: 'snprintf' output between 12 and 41 bytes into a destination of size 40
         192 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s.bin", ucode_prefix);
             |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Reported-by: default avatarkernel test robot <lkp@intel.com>
    Reviewed-by: default avatarMario Limonciello <mario.limonciello@amd.com>
    Signed-off-by: default avatarPratap Nirujogi <pratap.nirujogi@amd.com>
    Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
    7c2d3112
amdgpu_isp.c 4.83 KB