[PATCH] drm: rcar-du: dsi: Fix hsfreq range matching

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When iterating over hsfreqrange_table, rcar_mipi_dsi_parameters_calc()
may dereference the sentinel table entry. Fix the loop condition to
break as soon as a suitable entry is found, defined by the lower bound
of the frequency range stored in the table being equal to or higher than
the target frequency.

Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@xxxxxxxxxxxxxxxx>
---
I will squash this with "drm: rcar-du: Add R-Car DSI driver", but I'm
posting it separately to ease review.
---
 drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
index faf993eae564..891bb956fd61 100644
--- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
+++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
@@ -219,9 +219,8 @@ static void rcar_mipi_dsi_parameters_calc(struct rcar_mipi_dsi *dsi,
 	/* Find hsfreqrange */
 	hsfreq = fout_target * 2;
 	for (i = 0; i < ARRAY_SIZE(hsfreqrange_table); i++) {
-		if (hsfreq > hsfreqrange_table[i][0] &&
-			hsfreq <= hsfreqrange_table[i+1][0]) {
-			setup_info->hsfreqrange = hsfreqrange_table[i+1][1];
+		if (hsfreqrange_table[i][0] >= hsfreq) {
+			setup_info->hsfreqrange = hsfreqrange_table[i][1];
 			break;
 		}
 	}

base-commit: c18c8891111bb5e014e144716044991112f16833
prerequisite-patch-id: dc9121a1b85ea05bf3eae2b0ac2168d47101ee87
prerequisite-patch-id: 6754b2ec4caec03e235550004003fe63c1cc793b
prerequisite-patch-id: d69c605df34d40934fa5d4e00f23d5785105099d
prerequisite-patch-id: 7d9edfb4758cafe8aec92d32709c0ad25a50942c
prerequisite-patch-id: 86c526fb41f9f9cbe95c50ba8a140e20484f187f
prerequisite-patch-id: a9649b53b55858f023b8d3d29afb9be7ad39ea3b
-- 
Regards,

Laurent Pinchart




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux