Skip to contentSkip to conversation

drm/bridge: it6505: Fix unreachable loop increment in KSV list check

PATCH In review Dheeraj Reddy Jonnalagadda 2 participants 2 messages Jan 7, 2025 – Jan 8, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/bridge: it6505: Fix unreachable loop increment in KSV list check

The inner loop in it6505_hdcp_part2_ksvlist_check had an unreachable increment due to returning true before the loop could continue. Restructure the loop to only return after verifying all 5 entries match, making the loop increment reachable.

Fixes 0989c02c7a5c ("drm/bridge: it6505: fix HDCP CTS compare V matching")
---
 drivers/gpu/drm/bridge/ite-it6505.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +4 -2
index 88ef76a37fe6..2ff2245abdeb 100644
@@ -2255,8 +2255,10 @@ static bool it6505_hdcp_part2_ksvlist_check(struct it6505 *it6505)
 			    av[i][1] != av[i][2] || bv[i][0] != av[i][3])
 				break;
 
-			DRM_DEV_DEBUG_DRIVER(dev, "V' all match!! %d, %d", retry, i);
-			return true;
+			if (i == 4) {
+				DRM_DEV_DEBUG_DRIVER(dev, "V' all match!! %d, %d", retry, i);
+				return true;
+			}
 		}
 	}
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 17 lines · Dheeraj Reddy Jonnalagadda

The inner loop in it6505_hdcp_part2_ksvlist_check had an unreachable increment due to returning true before the loop could continue. Restructure the loop to only return after verifying all 5 entries match, making the loop increment reachable.

Fixes 0989c02c7a5c ("drm/bridge: it6505: fix HDCP CTS compare V matching")
---
 drivers/gpu/drm/bridge/ite-it6505.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +0 -0
index 88ef76a37fe6..2ff2245abdeb 100644

drivers/gpu/drm/bridge/ite-it6505.c static bool it6505_hdcp_part2_ksvlist_check(struct it6505 *it6505) · line 2261

Quoted 9 lines
drivers/gpu/drm/bridge/ite-it6505.c +4 -2
@@ -2255,8 +2255,10 @@ static bool it6505_hdcp_part2_ksvlist_check(struct it6505 *it6505)
 			    av[i][1] != av[i][2] || bv[i][0] != av[i][3])
 				break;
 
-			DRM_DEV_DEBUG_DRIVER(dev, "V' all match!! %d, %d", retry, i);
-			return true;
+			if (i == 4) {
+				DRM_DEV_DEBUG_DRIVER(dev, "V' all match!! %d, %d", retry, i);
+				return true;
+			}

I think, it's more idiomatic if you move it out of the loop.

Quoted 6 lines
drivers/gpu/drm/bridge/ite-it6505.c +0 -0
 		}
 	}
 
Signature · 1 line
2.34.1
Signature · 2 lines
With best wishes
Dmitry