diff options
| author | Jouni Högander <jouni.hogander@intel.com> | 2025-08-07 07:26:35 +0300 |
|---|---|---|
| committer | Jouni Högander <jouni.hogander@intel.com> | 2025-08-07 14:58:54 +0300 |
| commit | 5fe8d1dba706ee5234acef29c4410ade89170193 (patch) | |
| tree | 80b5e5d054a89c8ea1e17c1df3e65233897d3238 /drivers | |
| parent | f9b5bf76ea719a115502f9c1b20ab534ccd8194b (diff) | |
| download | linux-5fe8d1dba706ee5234acef29c4410ade89170193.tar.xz | |
drm/i915/dsi: Fix overflow issue in pclk parsing
Parsed divider p will overflow and is considered being valid in case
pll_ctl == 0.
Fix this by checking divider p before decreasing it. Also small improvement
is made by using fls() instead of custom loop.
v2: use fls() and check parsed divider
Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Link: https://lore.kernel.org/r/20250807042635.2491537-1-jouni.hogander@intel.com
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/gpu/drm/i915/display/vlv_dsi_pll.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/gpu/drm/i915/display/vlv_dsi_pll.c b/drivers/gpu/drm/i915/display/vlv_dsi_pll.c index b52463fdec47..83afe1315e96 100644 --- a/drivers/gpu/drm/i915/display/vlv_dsi_pll.c +++ b/drivers/gpu/drm/i915/display/vlv_dsi_pll.c @@ -142,11 +142,9 @@ static int vlv_dsi_pclk(struct intel_encoder *encoder, pll_div &= DSI_PLL_M1_DIV_MASK; pll_div = pll_div >> DSI_PLL_M1_DIV_SHIFT; - while (pll_ctl) { - pll_ctl = pll_ctl >> 1; - p++; - } - p--; + p = fls(pll_ctl); + if (p) + p--; if (!p) { drm_err(display->drm, "wrong P1 divisor\n"); |
