OSDN Git Service

drm/i915/dp: prevent potential div-by-zero
authorNikita Zhandarovich <n.zhandarovich@fintech.ru>
Tue, 18 Apr 2023 14:04:30 +0000 (07:04 -0700)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Fri, 5 May 2023 14:27:31 +0000 (10:27 -0400)
commit51f7008239de011370c5067bbba07f0207f06b72
tree64695f7e1fde033b80843359de41a9c3c9156f1a
parent1d5b09f8daf859247a1ea65b0d732a24d88980d8
drm/i915/dp: prevent potential div-by-zero

drm_dp_dsc_sink_max_slice_count() may return 0 if something goes
wrong on the part of the DSC sink and its DPCD register. This null
value may be later used as a divisor in intel_dsc_compute_params(),
which will lead to an error.
In the unlikely event that this issue occurs, fix it by testing the
return value of drm_dp_dsc_sink_max_slice_count() against zero.

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

Fixes: a4a157777c80 ("drm/i915/dp: Compute DSC pipe config in atomic check")
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230418140430.69902-1-n.zhandarovich@fintech.ru
drivers/gpu/drm/i915/display/intel_dp.c