[lvc-project] [PATCH v2] drm/radeon/rs780: avoid potential divide-by-zero in refresh rate calculation
Evgenii Burenchev
evg28bur at yandex.ru
Fri Jul 3 16:24:12 MSK 2026
The refresh rate used in rs780 DPM display configuration is derived from
drm_mode_vrefresh(crtc->mode). While connector modes are validated through
drm_mode_validate_driver(), crtc->mode represents runtime display state
and may originate from restore paths or transitional modeset states.
In such cases, drm_mode_vrefresh() may return 0, which is currently used
as a divisor in rs780_program_at(), leading to a potential divide-by-zero
condition.
This issue was found by Linux Verification Center (linuxtesting.org) with SVACE.
Fix this by enforcing a safe fallback refresh rate when the computed value
is zero.
This change ensures robustness of rs780 display power management during
resume and display reconfiguration paths.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 9d67006e6ebc ("drm/radeon: rs780 DPM display configuration handling")
Signed-off-by: Evgenii Burenchev <evg28bur at yandex.ru>
---
Changes in v2:
- Add Fixes tag referencing related rs780 DPM display configuration commit
- Clarify that issue is related to runtime crtc->mode state rather than
connector mode validation path
- Reword commit message to align with DRM state model terminology
---
drivers/gpu/drm/radeon/rs780_dpm.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/radeon/rs780_dpm.c b/drivers/gpu/drm/radeon/rs780_dpm.c
index 64bb4cafb8b5..ad7161972e37 100644
--- a/drivers/gpu/drm/radeon/rs780_dpm.c
+++ b/drivers/gpu/drm/radeon/rs780_dpm.c
@@ -63,8 +63,11 @@ static void rs780_get_pm_mode_parameters(struct radeon_device *rdev)
if (crtc && crtc->enabled) {
radeon_crtc = to_radeon_crtc(crtc);
pi->crtc_id = radeon_crtc->crtc_id;
- if (crtc->mode.htotal && crtc->mode.vtotal)
+ if (crtc->mode.htotal && crtc->mode.vtotal) {
pi->refresh_rate = drm_mode_vrefresh(&crtc->mode);
+ if (!pi->refresh_rate)
+ pi->refresh_rate = 60;
+ }
break;
}
}
--
2.43.0
More information about the lvc-project
mailing list