• Arnd Bergmann's avatar
    drm/amd: Use a constant format string for amdgpu_ucode_request · 02062042
    Arnd Bergmann authored
    Multiple files in amdgpu call amdgpu_ucode_request() with a fw_name
    variable that the compiler cannot check for being a valid format string,
    as seen by enabling the (default-disabled) -Wformat-security option:
    
    drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c: In function 'amdgpu_mes_init_microcode':
    drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c:1517:61: error: format not a string literal and no format arguments [-Werror=format-security]
     1517 |         r = amdgpu_ucode_request(adev, &adev->mes.fw[pipe], fw_name);
          |                                                             ^~~~~~~
    drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c: In function 'amdgpu_uvd_sw_init':
    drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c:263:9: error: format not a string literal and no format arguments [-Werror=format-security]
      263 |         r = amdgpu_ucode_request(adev, &adev->uvd.fw, fw_name);
          |         ^
    drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c: In function 'amdgpu_vce_sw_init':
    drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c:161:9: error: format not a string literal and no format arguments [-Werror=format-security]
      161 |         r = amdgpu_ucode_request(adev, &adev->vce.fw, fw_name);
          |         ^
    drivers/gpu/drm/amd/amdgpu/amdgpu_umsch_mm.c: In function 'amdgpu_umsch_mm_init_microcode':
    drivers/gpu/drm/amd/amdgpu/amdgpu_umsch_mm.c:590:9: error: format not a string literal and no format arguments [-Werror=format-security]
      590 |         r = amdgpu_ucode_request(adev, &adev->umsch_mm.fw, fw_name);
          |         ^
    drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c: In function 'amdgpu_cgs_get_firmware_info':
    drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c:417:72: error: format not a string literal and no format arguments [-Werror=format-security]
      417 |                         err = amdgpu_ucode_request(adev, &adev->pm.fw, fw_name);
          |                                                                        ^~~~~~~
    drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c: In function 'load_dmcu_fw':
    drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:2221:9: error: format not a string literal and no format arguments [-Werror=format-security]
     2221 |         r = amdgpu_ucode_request(adev, &adev->dm.fw_dmcu, fw_name_dmcu);
          |         ^
    drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c: In function 'dm_init_microcode':
    drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:5147:9: error: format not a string literal and no format arguments [-Werror=format-security]
     5147 |         r = amdgpu_ucode_request(adev, &adev->dm.dmub_fw, fw_name_dmub);
          |         ^
    
    Change these all to use a "%s" format with the actual name as an argument,
    to let the compiler prove this to be correct.
    
    Fixes: e5a7d047 ("drm/amd: Use `amdgpu_ucode_*` helpers for CGS")
    Fixes: 52215e2a ("drm/amd: Use `amdgpu_ucode_*` helpers for VCE")
    Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
    Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
    02062042
amdgpu_uvd.c 33.9 KB