Skip to content

Commit 4b6d66a

Browse files
Hans Verkuilmchehab
Hans Verkuil
authored andcommitted
media: v4l2-dv-timings: add sanity checks for blanking values
Add sanity checks to v4l2_valid_dv_timings() to ensure that the provided blanking values are reasonable. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Fixes: b18787e ([media] v4l2-dv-timings: add new helper module) Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
1 parent 1f65ea4 commit 4b6d66a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,20 @@ bool v4l2_valid_dv_timings(const struct v4l2_dv_timings *t,
161161
(bt->interlaced && !(caps & V4L2_DV_BT_CAP_INTERLACED)) ||
162162
(!bt->interlaced && !(caps & V4L2_DV_BT_CAP_PROGRESSIVE)))
163163
return false;
164+
165+
/* sanity checks for the blanking timings */
166+
if (!bt->interlaced &&
167+
(bt->il_vbackporch || bt->il_vsync || bt->il_vfrontporch))
168+
return false;
169+
if (bt->hfrontporch > 2 * bt->width ||
170+
bt->hsync > 1024 || bt->hbackporch > 1024)
171+
return false;
172+
if (bt->vfrontporch > 4096 ||
173+
bt->vsync > 128 || bt->vbackporch > 4096)
174+
return false;
175+
if (bt->interlaced && (bt->il_vfrontporch > 4096 ||
176+
bt->il_vsync > 128 || bt->il_vbackporch > 4096))
177+
return false;
164178
return fnc == NULL || fnc(t, fnc_handle);
165179
}
166180
EXPORT_SYMBOL_GPL(v4l2_valid_dv_timings);

0 commit comments

Comments
 (0)