The loop should exit at the lowest link rate, so break the loop at the lowest link rate without check. The check is always true because lowest link rate is smaller than current one and maximum of current display. Otherwise, it may be seen as the loop can potentially result in negative array offset. The patch d76271d22694: "drm: xlnx: DRM/KMS driver for Xilinx ZynqMP DisplayPort Subsystem" from Jul 7, 2018, leads to the following static checker warning: drivers/gpu/drm/xlnx/zynqmp_dp.c:594 zynqmp_dp_mode_configure() error: iterator underflow 'bws' (-1)-2 Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Signed-off-by: Hyun Kwon <hyun.kwon@xxxxxxxxxx> --- drivers/gpu/drm/xlnx/zynqmp_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c index b735072..1be2b19 100644 --- a/drivers/gpu/drm/xlnx/zynqmp_dp.c +++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c @@ -579,7 +579,7 @@ static int zynqmp_dp_mode_configure(struct zynqmp_dp *dp, int pclock, return -EINVAL; } - for (i = ARRAY_SIZE(bws) - 1; i >= 0; i--) { + for (i = ARRAY_SIZE(bws) - 1; i > 0; i--) { if (current_bw && bws[i] >= current_bw) continue; -- 2.7.4 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel