]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
drm/radeon: fix possible division-by-zero errors
authorNikita Zhandarovich <n.zhandarovich@fintech.ru>
Fri, 19 May 2023 15:33:27 +0000 (08:33 -0700)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Mon, 2 Oct 2023 15:19:45 +0000 (17:19 +0200)
commit08881c6b10ba680c11c1ccbb63a2b0e85220d5f2
tree6cb8ae6a189a59d7a8279250c678c9c5da76a82c
parente97a315738ee047689b032e618022cc1f9d908ca
drm/radeon: fix possible division-by-zero errors

BugLink: https://bugs.launchpad.net/bugs/2034469
[ Upstream commit 1becc57cd1a905e2aa0e1eca60d2a37744525c4a ]

Function rv740_get_decoded_reference_divider() may return 0 due to
unpredictable reference divider value calculated in
radeon_atom_get_clock_dividers(). This will lead to
division-by-zero error once that value is used as a divider
in calculating 'clk_s'.
While unlikely, this issue should nonetheless be prevented so add a
sanity check for such cases by testing 'decoded_ref' value against 0.

Found by Linux Verification Center (linuxtesting.org) with static
analysis tool SVACE.

v2: minor coding style fixes (Alex)
In practice this should actually happen as the vbios should be
properly populated.

Fixes: 66229b200598 ("drm/radeon/kms: add dpm support for rv7xx (v4)")
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/gpu/drm/radeon/cypress_dpm.c
drivers/gpu/drm/radeon/ni_dpm.c
drivers/gpu/drm/radeon/rv740_dpm.c