Commit 4108b3e6 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

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: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: default avatarKrzysztof Hałasa <khalasa@piap.pl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent f33fd8d7
...@@ -196,7 +196,7 @@ bool v4l2_find_dv_timings_cap(struct v4l2_dv_timings *t, ...@@ -196,7 +196,7 @@ bool v4l2_find_dv_timings_cap(struct v4l2_dv_timings *t,
if (!v4l2_valid_dv_timings(t, cap, fnc, fnc_handle)) if (!v4l2_valid_dv_timings(t, cap, fnc, fnc_handle))
return false; return false;
for (i = 0; i < v4l2_dv_timings_presets[i].bt.width; i++) { for (i = 0; v4l2_dv_timings_presets[i].bt.width; i++) {
if (v4l2_valid_dv_timings(v4l2_dv_timings_presets + i, cap, if (v4l2_valid_dv_timings(v4l2_dv_timings_presets + i, cap,
fnc, fnc_handle) && fnc, fnc_handle) &&
v4l2_match_dv_timings(t, v4l2_dv_timings_presets + i, 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) ...@@ -218,7 +218,7 @@ bool v4l2_find_dv_timings_cea861_vic(struct v4l2_dv_timings *t, u8 vic)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < v4l2_dv_timings_presets[i].bt.width; i++) { for (i = 0; v4l2_dv_timings_presets[i].bt.width; i++) {
const struct v4l2_bt_timings *bt = const struct v4l2_bt_timings *bt =
&v4l2_dv_timings_presets[i].bt; &v4l2_dv_timings_presets[i].bt;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment