]> git.baikalelectronics.ru Git - kernel.git/commit
drm/amd/powerplay: Fix buffer overflows with mc_reg_address
authorErnst Sjöstrand <ernstp@gmail.com>
Sun, 19 Nov 2017 17:52:45 +0000 (18:52 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 6 Dec 2017 17:48:00 +0000 (12:48 -0500)
commitb322f1a87261c651c0edd5a986acaa5f3f89c0e4
tree5be4edbbf04b699139ddecdfe76da8f2f5be35d0
parentff2bdb06b602dafcb1fd51f2973d3158d4eecfa6
drm/amd/powerplay: Fix buffer overflows with mc_reg_address

Smatch warned about the following lines:
ci_set_mc_special_registers() error: buffer overflow 'table->mc_reg_address' 16 <= 16
tonga_set_mc_special_registers() error: buffer overflow 'table->mc_reg_address' 16 <= 16

Change the logic to check before access instead of after incrementing.
It's fine if j reaches max after we're done. This allows the last entry
of the array to be filled without an error message for example.
Changed some whitespace to clarify grouping.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Ernst Sjöstrand <ernstp@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/ci_dpm.c
drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c