Skip to content

Commit 4108b3e

Browse files
Hans Verkuilmchehab
authored andcommitted
media: v4l2-dv-timings.c: fix wrong condition in two for-loops
These for-loops should test against v4l2_dv_timings_presets[i].bt.width, not if i < v4l2_dv_timings_presets[i].bt.width. Luckily nothing ever broke, since the smallest width is still a lot higher than the total number of presets, but it is wrong. The last item in the presets array is all 0, so the for-loop must stop when it reaches that sentinel. Signed-off-by: Hans Verkuil <[email protected]> Reported-by: Krzysztof Hałasa <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent f33fd8d commit 4108b3e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/media/v4l2-core/v4l2-dv-timings.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ bool v4l2_find_dv_timings_cap(struct v4l2_dv_timings *t,
196196
if (!v4l2_valid_dv_timings(t, cap, fnc, fnc_handle))
197197
return false;
198198

199-
for (i = 0; i < v4l2_dv_timings_presets[i].bt.width; i++) {
199+
for (i = 0; v4l2_dv_timings_presets[i].bt.width; i++) {
200200
if (v4l2_valid_dv_timings(v4l2_dv_timings_presets + i, cap,
201201
fnc, fnc_handle) &&
202202
v4l2_match_dv_timings(t, v4l2_dv_timings_presets + i,
@@ -218,7 +218,7 @@ bool v4l2_find_dv_timings_cea861_vic(struct v4l2_dv_timings *t, u8 vic)
218218
{
219219
unsigned int i;
220220

221-
for (i = 0; i < v4l2_dv_timings_presets[i].bt.width; i++) {
221+
for (i = 0; v4l2_dv_timings_presets[i].bt.width; i++) {
222222
const struct v4l2_bt_timings *bt =
223223
&v4l2_dv_timings_presets[i].bt;
224224

0 commit comments

Comments
 (0)