]> www.infradead.org Git - nvme.git/commit
drm/i915: Fix possible int overflow in skl_ddi_calculate_wrpll()
authorNikita Zhandarovich <n.zhandarovich@fintech.ru>
Mon, 29 Jul 2024 17:40:35 +0000 (10:40 -0700)
committerJani Nikula <jani.nikula@intel.com>
Tue, 30 Jul 2024 11:41:09 +0000 (14:41 +0300)
commit833cf12846aa19adf9b76bc79c40747726f3c0c1
tree31a631c94d64b127ea1beb6899c4f25916afdd3e
parent73d7cd542bbd0a7c6881ea0df5255f190a1e7236
drm/i915: Fix possible int overflow in skl_ddi_calculate_wrpll()

On the off chance that clock value ends up being too high (by means
of skl_ddi_calculate_wrpll() having been called with big enough
value of crtc_state->port_clock * 1000), one possible consequence
may be that the result will not be able to fit into signed int.

Fix this issue by moving conversion of clock parameter from kHz to Hz
into the body of skl_ddi_calculate_wrpll(), as well as casting the
same parameter to u64 type while calculating the value for AFE clock.
This both mitigates the overflow problem and avoids possible erroneous
integer promotion mishaps.

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

Fixes: 82d354370189 ("drm/i915/skl: Implementation of SKL DPLL programming")
Cc: stable@vger.kernel.org
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240729174035.25727-1-n.zhandarovich@fintech.ru
drivers/gpu/drm/i915/display/intel_dpll_mgr.c